Make WordPress Core

Changeset 52815


Ignore:
Timestamp:
03/02/2022 03:38:27 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Docs: Add a @since note for WP::parse_request() about the new return value.

Includes minor code layout fixes for consistency. Additionally, this moves a more general unit test above the more specific one.

Follow-up to [52814].

See #10886.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp.php

    r52814 r52815  
    126126     *
    127127     * @since 2.0.0
     128     * @since 6.0.0 A return value was added.
    128129     *
    129130     * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
     
    759760    public function main( $query_args = '' ) {
    760761        $this->init();
     762
    761763        $parsed = $this->parse_request( $query_args );
     764
    762765        $this->send_headers();
     766
    763767        if ( $parsed ) {
    764768            $this->query_posts();
     
    766770            $this->register_globals();
    767771        }
     772
    768773        /**
    769774         * Fires once the WordPress environment has been set up.
  • trunk/tests/phpunit/tests/wp/parseRequest.php

    r52814 r52815  
    1717
    1818    /**
    19      * Test that PHP 8.1 "passing null to non-nullable" deprecation notice
     19     * Tests the return value of the parse_request() method.
     20     *
     21     * @ticket 10886
     22     */
     23    public function test_parse_request_returns_bool() {
     24        // Check that parse_request() returns true by default.
     25        $this->assertTrue( $this->wp->parse_request() );
     26
     27        add_filter( 'do_parse_request', '__return_false' );
     28
     29        // Check that parse_request() returns false if the request was not parsed.
     30        $this->assertFalse( $this->wp->parse_request() );
     31    }
     32
     33    /**
     34     * Tests that PHP 8.1 "passing null to non-nullable" deprecation notice
    2035     * is not thrown when the home URL has no path/trailing slash (default setup).
    2136     *
     
    4055        $this->assertSame( '', $this->wp->request );
    4156    }
    42     /**
    43      * Test that the parse_request() returns bool
    44      *
    45      * @ticket 10886
    46      */
    47     public function test_parse_request_returns_bool() {
    48 
    49         // check if parse_request() returns true for default setup.
    50         $this->assertTrue( $this->wp->parse_request(), 'returns true' );
    51 
    52         // add filter to shortcut the parse_request function.
    53         add_filter( 'do_parse_request', '__return_false' );
    54         $this->assertFalse( $this->wp->parse_request(), 'returns false' );
    55         remove_filter( 'do_parse_request', '__return_false' );
    56 
    57     }
    5857}
Note: See TracChangeset for help on using the changeset viewer.