From cebbabbe2127313de6f8182e7fc400b59cdf1168 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 22 Feb 2021 18:53:11 +0000 Subject: [PATCH] Media: Explicitly declare the `$pagenow` global in `wp_get_attachment_url()`. This avoids an "Undefined index" PHP notice in the function when running the `media` test group separately. Follow-up to [32342], [50156], [50164], [50393]. Props johnbillion. Fixes #52606. git-svn-id: https://develop.svn.wordpress.org/trunk@50406 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index b46d97bf14..93a1b59adf 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -6277,6 +6277,8 @@ function wp_update_attachment_metadata( $attachment_id, $data ) { * @return string|false Attachment URL, otherwise false. */ function wp_get_attachment_url( $attachment_id = 0 ) { + global $pagenow; + $attachment_id = (int) $attachment_id; $post = get_post( $attachment_id ); @@ -6319,7 +6321,7 @@ function wp_get_attachment_url( $attachment_id = 0 ) { } // On SSL front end, URLs should be HTTPS. - if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $GLOBALS['pagenow'] ) { + if ( is_ssl() && ! is_admin() && 'wp-login.php' !== $pagenow ) { $url = set_url_scheme( $url ); }