Call func_get_args() once in add_query_arg(). Props SergeyBiryukov. see #21332

git-svn-id: http://core.svn.wordpress.org/trunk@21373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2012-07-31 15:28:10 +00:00
parent 4768331a77
commit 4630ae82ce
1 changed files with 9 additions and 8 deletions

View File

@ -637,16 +637,17 @@ function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=t
*/ */
function add_query_arg() { function add_query_arg() {
$ret = ''; $ret = '';
if ( is_array( func_get_arg(0) ) ) { $args = func_get_args();
if ( func_num_args() < 2 || false === func_get_arg( 1 ) ) if ( is_array( $args[0] ) ) {
if ( count( $args ) < 2 || false === $args[1] )
$uri = $_SERVER['REQUEST_URI']; $uri = $_SERVER['REQUEST_URI'];
else else
$uri = func_get_arg( 1 ); $uri = $args[1];
} else { } else {
if ( func_num_args() < 3 || false === func_get_arg( 2 ) ) if ( count( $args ) < 3 || false === $args[2] )
$uri = $_SERVER['REQUEST_URI']; $uri = $_SERVER['REQUEST_URI'];
else else
$uri = func_get_arg( 2 ); $uri = $args[2];
} }
if ( $frag = strstr( $uri, '#' ) ) if ( $frag = strstr( $uri, '#' ) )
@ -680,11 +681,11 @@ function add_query_arg() {
wp_parse_str( $query, $qs ); wp_parse_str( $query, $qs );
$qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string $qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string
if ( is_array( func_get_arg( 0 ) ) ) { if ( is_array( $args[0] ) ) {
$kayvees = func_get_arg( 0 ); $kayvees = $args[0];
$qs = array_merge( $qs, $kayvees ); $qs = array_merge( $qs, $kayvees );
} else { } else {
$qs[func_get_arg( 0 )] = func_get_arg( 1 ); $qs[ $args[0] ] = $args[1];
} }
foreach ( (array) $qs as $k => $v ) { foreach ( (array) $qs as $k => $v ) {