Make WordPress Core


Ignore:
Timestamp:
08/29/2023 10:03:25 PM (18 months ago)
Author:
joemcgill
Message:

Posts, Post Types: Reinstate missing sort_column options in get_pages().

This fixes an issue introduced in [55569] that broke sort ordering by post_modified_gmt or modified_gmt.

Props david.binda, azaozz, spacedmonkey, flixos90, joemcgill.
Fixes #59226.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getPages.php

    r55845 r56490  
    11821182        );
    11831183    }
     1184
     1185    /**
     1186     * Tests that the legacy `post_modified_gmt` orderby values are translated to the proper `WP_Query` values.
     1187     *
     1188     * @ticket 59226
     1189     */
     1190    public function test_get_pages_order_by_post_modified_gmt() {
     1191        global $wpdb;
     1192
     1193        get_pages(
     1194            array(
     1195                'sort_column' => 'post_modified_gmt',
     1196            )
     1197        );
     1198        $this->assertStringContainsString(
     1199            "ORDER BY $wpdb->posts.post_modified ASC",
     1200            $wpdb->last_query,
     1201            'Check that ORDER is post modified when using post_modified_gmt.'
     1202        );
     1203
     1204        get_pages(
     1205            array(
     1206                'sort_column' => 'modified_gmt',
     1207            )
     1208        );
     1209        $this->assertStringContainsString(
     1210            "ORDER BY $wpdb->posts.post_modified ASC",
     1211            $wpdb->last_query,
     1212            'Check that ORDER is post modified when using modified_gmt.'
     1213        );
     1214    }
    11841215}
Note: See TracChangeset for help on using the changeset viewer.