From 36ee9bde3e8b7b051eb8b47d307b64d794623eb2 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Fri, 14 Jun 2024 15:19:20 +0000 Subject: [PATCH] Options: Fix some default autoload values used in core. This fixes some autoload values that were updated in [58105] that used the database values of `"on"` and `"off"` instead of the boolean values `true` and `false` when being passed to `add|update_option()`. Props joemcgill, desrosj, rajinsharwar. Fixes #61045. See #42441. git-svn-id: https://develop.svn.wordpress.org/trunk@58416 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ajax-actions.php | 6 +++--- src/wp-includes/option.php | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 985497641dc17..62feaffc6d077 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -192,7 +192,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 0 ); } else { - update_option( 'can_compress_scripts', 0, 'on' ); + update_option( 'can_compress_scripts', 0, true ); } wp_die( 0 ); } @@ -231,7 +231,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 0 ); } else { - update_option( 'can_compress_scripts', 0, 'on' ); + update_option( 'can_compress_scripts', 0, true ); } } elseif ( 'yes' === $_GET['test'] ) { check_ajax_referer( 'update_can_compress_scripts' ); @@ -239,7 +239,7 @@ function wp_ajax_wp_compression_test() { if ( is_multisite() ) { update_site_option( 'can_compress_scripts', 1 ); } else { - update_option( 'can_compress_scripts', 1, 'on' ); + update_option( 'can_compress_scripts', 1, true ); } } } diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index c454e1119d85d..4dee6ce1188e9 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -1514,10 +1514,10 @@ function set_transient( $transient, $value, $expiration = 0 ) { wp_prime_option_caches( array( $transient_option, $transient_timeout ) ); if ( false === get_option( $transient_option ) ) { - $autoload = 'on'; + $autoload = true; if ( $expiration ) { - $autoload = 'off'; - add_option( $transient_timeout, time() + $expiration, '', 'off' ); + $autoload = false; + add_option( $transient_timeout, time() + $expiration, '', false ); } $result = add_option( $transient_option, $value, '', $autoload ); } else { @@ -1530,8 +1530,8 @@ function set_transient( $transient, $value, $expiration = 0 ) { if ( $expiration ) { if ( false === get_option( $transient_timeout ) ) { delete_option( $transient_option ); - add_option( $transient_timeout, time() + $expiration, '', 'off' ); - $result = add_option( $transient_option, $value, '', 'off' ); + add_option( $transient_timeout, time() + $expiration, '', false ); + $result = add_option( $transient_option, $value, '', false ); $update = false; } else { update_option( $transient_timeout, time() + $expiration ); @@ -2119,7 +2119,7 @@ function add_network_option( $network_id, $option, $value ) { $notoptions_key = "$network_id:notoptions"; if ( ! is_multisite() ) { - $result = add_option( $option, $value, '', 'off' ); + $result = add_option( $option, $value, '', false ); } else { $cache_key = "$network_id:$option"; @@ -2365,7 +2365,7 @@ function update_network_option( $network_id, $option, $value ) { } if ( ! is_multisite() ) { - $result = update_option( $option, $value, 'off' ); + $result = update_option( $option, $value, false ); } else { $value = sanitize_option( $option, $value );