Make WordPress Core


Ignore:
Timestamp:
06/14/2022 12:40:29 PM (22 months ago)
Author:
spacedmonkey
Message:

REST API: Avoid duplicated query in post collections.

Avoid duplicated query when retrieving empty posts collections by adding a check if the page is more than 1.

Props furi3r, gdetassigny, TimothyBlynJacobs, spacedmonkey.
Fixes #55677.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r52389 r53498  
    13861386        $this->assertCount( 0, $response->get_data() );
    13871387
    1388         // FIXME Since this request returns zero posts, the query is executed twice.
    1389         $this->assertCount( 2, $this->posts_clauses );
     1388        $this->assertCount( 1, $this->posts_clauses );
    13901389        $this->posts_clauses = array_slice( $this->posts_clauses, 0, 1 );
    13911390
     
    14181417        $this->assertCount( 0, $response->get_data() );
    14191418
    1420         // FIXME Since this request returns zero posts, the query is executed twice.
    1421         $this->assertCount( 2, $this->posts_clauses );
     1419        $this->assertCount( 1, $this->posts_clauses );
    14221420        $this->posts_clauses = array_slice( $this->posts_clauses, 0, 1 );
    14231421
     
    14371435        $this->assertCount( 0, $response->get_data() );
    14381436
    1439         // FIXME Since this request returns zero posts, the query is executed twice.
    1440         $this->assertCount( 2, $this->posts_clauses );
     1437        $this->assertCount( 1, $this->posts_clauses );
    14411438        $this->posts_clauses = array_slice( $this->posts_clauses, 0, 1 );
    14421439
Note: See TracChangeset for help on using the changeset viewer.