Skip to content

Commit

Permalink
Options: Update default autoload values used in core.
Browse files Browse the repository at this point in the history
This updates the values used for the `$autoload` parameter in various functions to replace 'yes' and 'no' with 'on' and 'off', respectively.

Follow-up to [57920].

Props pbearne, mukesh27, joemcgill.
Fixes #61045. See #42441.


git-svn-id: https://develop.svn.wordpress.org/trunk@58105 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
joemcgill committed May 6, 2024
1 parent be9f8a5 commit d1d0f68
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 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, 'yes' );
update_option( 'can_compress_scripts', 0, 'on' );
}
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, 'yes' );
update_option( 'can_compress_scripts', 0, 'on' );
}
} 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, 'yes' );
update_option( 'can_compress_scripts', 1, 'on' );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ public static function create_lock( $lock_name, $release_timeout = null ) {
$lock_option = $lock_name . '.lock';

// Try to lock.
$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_option, time() ) );
$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'off') /* LOCK */", $lock_option, time() ) );

if ( ! $lock_result ) {
$lock_result = get_option( $lock_option );
Expand Down
4 changes: 2 additions & 2 deletions src/wp-admin/includes/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,9 @@ function populate_options( array $options = array() ) {
}

if ( in_array( $option, $fat_options, true ) ) {
$autoload = 'no';
$autoload = 'off';
} else {
$autoload = 'yes';
$autoload = 'on';
}

if ( ! empty( $insert ) ) {
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 @@ -1412,10 +1412,10 @@ function set_transient( $transient, $value, $expiration = 0 ) {
$transient_option = '_transient_' . $transient;

if ( false === get_option( $transient_option ) ) {
$autoload = 'yes';
$autoload = 'on';
if ( $expiration ) {
$autoload = 'no';
add_option( $transient_timeout, time() + $expiration, '', 'no' );
$autoload = 'off';
add_option( $transient_timeout, time() + $expiration, '', 'off' );
}
$result = add_option( $transient_option, $value, '', $autoload );
} else {
Expand All @@ -1428,8 +1428,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, '', 'no' );
$result = add_option( $transient_option, $value, '', 'no' );
add_option( $transient_timeout, time() + $expiration, '', 'off' );
$result = add_option( $transient_option, $value, '', 'off' );
$update = false;
} else {
update_option( $transient_timeout, time() + $expiration );
Expand Down Expand Up @@ -2017,7 +2017,7 @@ function add_network_option( $network_id, $option, $value ) {
$notoptions_key = "$network_id:notoptions";

if ( ! is_multisite() ) {
$result = add_option( $option, $value, '', 'no' );
$result = add_option( $option, $value, '', 'off' );
} else {
$cache_key = "$network_id:$option";

Expand Down Expand Up @@ -2263,7 +2263,7 @@ function update_network_option( $network_id, $option, $value ) {
}

if ( ! is_multisite() ) {
$result = update_option( $option, $value, 'no' );
$result = update_option( $option, $value, 'off' );
} else {
$value = sanitize_option( $option, $value );

Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ function _wp_upgrade_revisions_of_post( $post, $revisions ) {
// Add post option exclusively.
$lock = "revision-upgrade-{$post->ID}";
$now = time();
$result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'no') /* LOCK */", $lock, $now ) );
$result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'off') /* LOCK */", $lock, $now ) );

if ( ! $result ) {
// If we couldn't get a lock, see how old the previous lock is.
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4365,7 +4365,7 @@ function _wp_batch_split_terms() {
$lock_name = 'term_split.lock';

// Try to lock.
$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'no') /* LOCK */", $lock_name, time() ) );
$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'off') /* LOCK */", $lock_name, time() ) );

if ( ! $lock_result ) {
$lock_result = get_option( $lock_name );
Expand Down

0 comments on commit d1d0f68

Please sign in to comment.