Skip to content

Commit 37f91b7

Browse files
Bootstrap/Load: Avoid a PHP warning when setting the $pagenow global in wp-includes/vars.php.
In some scenarios where `is_admin()` returns true but `$_SERVER['PHP_SELF']` does not match a `wp-admin/*` location, setting the `$pagenow` global could trigger a PHP warning: `Undefined array key 1`. This commit avoids the warning by checking whether the matches array is not empty. Props janh2, konradyoast, peterwilsoncc. Fixes #54700. git-svn-id: https://develop.svn.wordpress.org/trunk@53294 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d47a44a commit 37f91b7

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/wp-includes/vars.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
} else {
3030
preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches );
3131
}
32-
$pagenow = $self_matches[1];
32+
33+
$pagenow = ! empty( $self_matches[1] ) ? $self_matches[1] : '';
3334
$pagenow = trim( $pagenow, '/' );
3435
$pagenow = preg_replace( '#\?.*?$#', '', $pagenow );
36+
3537
if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
3638
$pagenow = 'index.php';
3739
} else {

0 commit comments

Comments
 (0)