WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/01/2015 07:14:46 PM (6 years ago)
Author:
wonderboymusic
Message:

Respect numerical keys in add_query_arg(), use array_replace() instead of array_merge().

Adds unit test.

Props tyxla.
Fixes #31306.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r31311 r31966  
    257257
    258258        $_SERVER['REQUEST_URI'] = $old_req_uri;
     259    }
     260
     261    /**
     262     * @ticket 31306
     263     */
     264    function test_add_query_arg_numeric_keys() {
     265        $url = add_query_arg( array( 'foo' => 'bar' ), '1=1' );
     266        $this->assertEquals('1=1&foo=bar', $url);
     267
     268        $url = add_query_arg( array( 'foo' => 'bar', '1' => '2' ), '1=1' );
     269        $this->assertEquals('1=2&foo=bar', $url);
     270
     271        $url = add_query_arg( array( '1' => '2' ), 'foo=bar' );
     272        $this->assertEquals('foo=bar&1=2', $url);
    259273    }
    260274
Note: See TracChangeset for help on using the changeset viewer.