Commit 01ed44f185 for wordpress.org
commit 01ed44f1851d5c5ede903458f083c97a3c4c8b7c
Author: peterwilsoncc <peterwilsoncc@git.wordpress.org>
Date: Fri Oct 30 01:00:55 2026 +0000
Rewrites: Reinstate split the query for random redirects.
Removes the filtering of `split_the_query` to `false` on random post redirects. As sorting queries randomly generates a temporary table, selecting `*` places all data in the temporary table, whereas selecting `ID` only places the post ID in the temporary table. The unsplit query can become inefficient on sites with a relatively few posts (ie, thousands not millions).
This removes the function `wp_random_content_split_the_query()` with a hard deprecation as it was not released to a production version of WordPress.
Additionally, the following changes have been made to the test suite:
* Tests ensuring random redirects are not cached are refactored to avoid the `$this->go_to()` method in the test suite as the helper method flushes the cache, causing the tests to be invalid
* Introduces tests covering `WP::handle_random()` specifically
* Adds docblocks to each and every test in `Tests_Query_RandomContentRedirect`
Developed in https://github.com/WordPress/wordpress-develop/pull/14809.
Follow-up to r63767, r63906, r64402.
Props aryanjasala, peterwilsoncc, dhrupo, westonruter.
Fixes #64498.
Built from https://develop.svn.wordpress.org/trunk@65042
git-svn-id: http://core.svn.wordpress.org/trunk@64192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
index 7f5f9d0fb0..3c1234f9cf 100644
--- a/wp-includes/default-filters.php
+++ b/wp-includes/default-filters.php
@@ -496,7 +496,6 @@ add_action( 'post_updated', 'wp_check_for_changed_dates', 12, 3 );
add_action( 'attachment_updated', 'wp_check_for_changed_dates', 12, 3 );
// Random content redirects, see WP::handle_random().
-add_filter( 'split_the_query', 'wp_random_content_split_the_query', 10, 2 );
add_action( 'wp_after_insert_post', 'wp_random_content_flush_rewrite_rules_for_post', 10, 4 );
add_action( 'after_delete_post', 'wp_random_content_flush_rewrite_rules_for_post', 10, 2 );
diff --git a/wp-includes/query.php b/wp-includes/query.php
index 212ac1619e..4cafca3d7c 100644
--- a/wp-includes/query.php
+++ b/wp-includes/query.php
@@ -1461,27 +1461,6 @@ function wp_random_content_post_limits( $limits, WP_Query $query ): string {
return (string) $limits;
}
-/**
- * Prevents the random content query from being split into multiple database queries.
- *
- * Randomly ordered queries are not cached, so there is no benefit to querying the post
- * IDs separately to the post objects. Disabling the split allows the random post to be
- * retrieved in a single database query.
- *
- * @since 7.2.0
- *
- * @param bool $split_the_query Whether or not to split the query.
- * @param WP_Query $query The WP_Query instance.
- * @return bool Whether or not to split the query.
- */
-function wp_random_content_split_the_query( $split_the_query, WP_Query $query ): bool {
- if ( wp_is_random_content_query( $query ) ) {
- return false;
- }
-
- return (bool) $split_the_query;
-}
-
/**
* Redirects random content requests to the randomly selected post.
*
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 39add71ee0..60be0ee02d 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta3-65041';
+$wp_version = '7.2-beta3-65042';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.