From 048c5ba580eb2477bc3ac17c15c8e5f376efe268 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Sat, 11 May 2024 23:53:15 +0000 Subject: [PATCH] Options, Meta APIs: Prime transient options prior to use. Reduce the number of queries getting and setting transients on sites without a persistent cache. Transients are stored in two options: one each for the transient value and timeout. Priming the cache reduces the database queries for getting a transient from two to one. Props peterwilsoncc, swissspidy. Fixes #61193. Built from https://develop.svn.wordpress.org/trunk@58134 git-svn-id: http://core.svn.wordpress.org/trunk@57599 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/option.php | 4 +++- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/option.php b/wp-includes/option.php index 66b22e9fc4..344dfee088 100644 --- a/wp-includes/option.php +++ b/wp-includes/option.php @@ -1330,7 +1330,8 @@ function get_transient( $transient ) { if ( ! isset( $alloptions[ $transient_option ] ) ) { $transient_timeout = '_transient_timeout_' . $transient; - $timeout = get_option( $transient_timeout ); + wp_prime_option_caches( array( $transient_option, $transient_timeout ) ); + $timeout = get_option( $transient_timeout ); if ( false !== $timeout && $timeout < time() ) { delete_option( $transient_option ); delete_option( $transient_timeout ); @@ -1410,6 +1411,7 @@ function set_transient( $transient, $value, $expiration = 0 ) { } else { $transient_timeout = '_transient_timeout_' . $transient; $transient_option = '_transient_' . $transient; + wp_prime_option_caches( array( $transient_option, $transient_timeout ) ); if ( false === get_option( $transient_option ) ) { $autoload = 'on'; diff --git a/wp-includes/version.php b/wp-includes/version.php index 104cd45ed3..8b59ad54ae 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-58133'; +$wp_version = '6.6-alpha-58134'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.