Skip to content

Commit

Permalink
Options: Fix some default autoload values used in core.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joemcgill committed Jun 14, 2024
1 parent 0e7e596 commit 36ee9bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/wp-admin/includes/ajax-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -231,15 +231,15 @@ 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' );
// Use `update_option()` on single site to mark the option for autoloading.
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 );
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/wp-includes/option.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 );
Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -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 );

Expand Down

0 comments on commit 36ee9bd

Please sign in to comment.