Skip to content

Commit bfd1007

Browse files
committed
lint
1 parent 8af48fd commit bfd1007

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/wp-includes/class-wp-query.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3324,8 +3324,8 @@ public function get_posts() {
33243324
}
33253325

33263326
$cache_key = $this->generate_cache_key( $query_vars, $new_request );
3327-
33283327
$cache_found = false;
3328+
33293329
if ( null === $this->posts ) {
33303330
$cached_results = wp_cache_get_salted( $cache_key, 'post-queries', $last_changed );
33313331

@@ -5109,12 +5109,14 @@ protected function generate_cache_key( array $args, $sql ) {
51095109
sort( $args['post_status'] );
51105110
}
51115111

5112-
// Add a default orderby value of date to ensure same cache key generation.
5113-
// Add a default orderby value of date to ensure same cache key generation.
5112+
5113+
/*
5114+
* Ensure deterministic ordering to prevent duplicate records across pages.
5115+
* When multiple posts have the same value for a field, add ID as secondary sort to guarantee consistent ordering.
5116+
*/
51145117
if ( ! isset( $args['orderby'] ) ) {
51155118
$args['orderby'] = 'date, ID';
5116-
} elseif ( $args['orderby'] === 'date' ) {
5117-
// Normalize 'date' to 'date, ID' to match deterministic ordering
5119+
} elseif ( 'date' === $args['orderby'] ) {
51185120
$args['orderby'] = 'date, ID';
51195121
}
51205122

0 commit comments

Comments
 (0)