Changeset 56517
- Timestamp:
- 09/05/2023 08:46:19 PM (13 months ago)
- Location:
- branches/6.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.3
-
branches/6.3/src/wp-includes/post.php
r56516 r56517 6067 6067 } 6068 6068 6069 /* 6070 * Maintain backward compatibility for `sort_column` key. 6071 * Additionally to `WP_Query`, it has been supporting the `post_modified_gmt` field, so this logic will translate 6072 * it to `post_modified` which should result in the same order given the two dates in the fields match. 6073 */ 6069 6074 $orderby = wp_parse_list( $parsed_args['sort_column'] ); 6070 $orderby = array_map( 'trim', $orderby ); 6075 $orderby = array_map( 6076 static function( $orderby_field ) { 6077 $orderby_field = trim( $orderby_field ); 6078 if ( 'post_modified_gmt' === $orderby_field || 'modified_gmt' === $orderby_field ) { 6079 $orderby_field = str_replace( '_gmt', '', $orderby_field ); 6080 } 6081 return $orderby_field; 6082 }, 6083 $orderby 6084 ); 6071 6085 if ( $orderby ) { 6072 6086 $query_args['orderby'] = array_fill_keys( $orderby, $parsed_args['sort_order'] ); -
branches/6.3/tests/phpunit/tests/post/getPages.php
r55845 r56517 1182 1182 ); 1183 1183 } 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 } 1184 1215 }
Note: See TracChangeset
for help on using the changeset viewer.