[wp-trac] [WordPress Trac] #31306: add_query_arg changes numerical arguments

WordPress Trac noreply at wordpress.org
Thu Feb 12 10:44:30 UTC 2015


#31306: add_query_arg changes numerical arguments
--------------------------+-----------------------------
 Reporter:  Lex_Robinson  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I noticed this when I used '1=1' as a default query value to prevent a ?
 being prepended. If an argument passed to add_query_arg is a number, it
 gets replaced with an incrementing value. It doesn't re-order arguments or
 parse non-decimal numbers.
 I suspect this is being caused by array_merge on line 782 of wp-
 includes/functions.php
 {{{#!php
 var_dump( add_query_arg( array( 'foo' => 'bar' ), '1=1' ) );
 // string '0=1&foo=bar' (length=11)

 var_dump( add_query_arg( array( 'a' => 'c' ), '1=1&a=b&10=10' ) );
 // string '0=1&a=c&1=10' (length=12)

 var_dump( add_query_arg( array( '19' => '19' ), '20=20' ) );
 // string '0=20&1=19' (length=9)

 var_dump( add_query_arg( array( '3e1' => '3' ), '0x1=1&a=b&010=2' ) );
 // string '0x1=1&a=b&010=2&3e1=3' (length=21)
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31306>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list