[wp-trac] [WordPress Trac] #54700: wp-includes/vars.php can trigger warning
WordPress Trac
noreply at wordpress.org
Mon Dec 27 16:48:20 UTC 2021
#54700: wp-includes/vars.php can trigger warning
--------------------------+-----------------------------
Reporter: janh2 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.8.2
Severity: minor | Keywords:
Focuses: |
--------------------------+-----------------------------
Some plugins are calling wp-load.php directly and handle the requests by
hooking into actions (InfiniteWP in my case, "/wp-
load.php?no_cache_XXXXX=1234567890", but I've seen it before in a
different setting that I can't recall) which leads to warnings while
setting $pagenow when using php8 (E_WARNING: Undefined array key 1 in wp-
includes/vars.php:32).
wp-includes/vars.php lines 25-32
{{{#!php
<?php
if ( is_network_admin() ) {
preg_match( '#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'],
$self_matches );
} elseif ( is_user_admin() ) {
preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'],
$self_matches );
} else {
preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'],
$self_matches );
}
$pagenow = $self_matches[1];
}}}
If the preg_match does not match, $self_matches will be an empty array.
It's not really caused by WP (since the plugin is not using official
APIs), but since this code can be hit in that way, I believe it should
check whether a match has occurred.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54700>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list