[wp-trac] [WordPress Trac] #49391: small notice in add_query_arg
WordPress Trac
noreply at wordpress.org
Sun Feb 9 23:36:19 UTC 2020
#49391: small notice in add_query_arg
--------------------------+-----------------------------
Reporter: quasibrodo | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.2.5
Severity: trivial | Keywords:
Focuses: |
--------------------------+-----------------------------
Admittedly I noticed this problem on wp 5.2.5 and I do see that the
function has been updated in 5.3 but in in add_query_arg(), this snippet:
if ( is_array( $args[0] ) ) {
foreach ( $args[0] as $k => $v ) {
$qs[ $k ] = $v;
}
} else {
$qs[ $args[0] ] = $args[1]; //this is line 964
}
produces the following error.
Notice: Undefined offset: 1 in /home/centerforpublich/public_html/wp-
includes/functions.php on line 964
though I see that line is now 1114 on 5.3.2
I'm not certain if its a flaw with the logic of the function or if its
being called without the proper arguments but a simple fix that I
implemented to remove the notice was changing the above snippet to the
following:
if ( is_array( $args[0] ) ) {
foreach ( $args[0] as $k => $v ) {
$qs[ $k ] = $v;
}
} else if ( isset( $args[1] ) ) {
$qs[ $args[0] ] = $args[1];
}
It seems that for some reason it cannot be assumed that $args[1] will
always be set.
I hope this helps.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49391>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list