Changeset 58945
- Timestamp:
- 08/28/2024 04:39:30 PM (5 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/upgrade.php
r58810 r58945 1845 1845 $uninstall_plugins = get_option( 'uninstall_plugins' ); 1846 1846 delete_option( 'uninstall_plugins' ); 1847 add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no');1847 add_option( 'uninstall_plugins', $uninstall_plugins, null, false ); 1848 1848 } 1849 1849 } … … 2341 2341 if ( false !== $can_compress_scripts ) { 2342 2342 delete_option( 'can_compress_scripts' ); 2343 add_option( 'can_compress_scripts', $can_compress_scripts, '', 'yes');2343 add_option( 'can_compress_scripts', $can_compress_scripts, '', true ); 2344 2344 } 2345 2345 } … … 2394 2394 ); 2395 2395 2396 $autoload = array_fill_keys( $theme_mods_options, 'no');2396 $autoload = array_fill_keys( $theme_mods_options, false ); 2397 2397 wp_set_option_autoload_values( $autoload ); 2398 2398 } -
trunk/tests/phpunit/tests/option/option.php
r58782 r58945 144 144 */ 145 145 public function test_get_option_notoptions_do_not_load_cache() { 146 add_option( 'foo', 'bar', '', 'no');146 add_option( 'foo', 'bar', '', false ); 147 147 wp_cache_delete( 'notoptions', 'options' ); 148 148 … … 361 361 return array( 362 362 // Supported values. 363 array( 'autoload_yes', 'yes', 'on' ),364 363 array( 'autoload_true', true, 'on' ), 365 array( 'autoload_no', 'no', 'off' ),366 364 array( 'autoload_false', false, 'off' ), 367 365 array( 'autoload_null', null, 'auto' ), 366 367 // Values supported for backward compatibility. 368 array( 'autoload_yes', 'yes', 'on' ), 369 array( 'autoload_no', 'no', 'off' ), 368 370 369 371 // Technically unsupported values. … … 458 460 */ 459 461 public function test_update_option_with_autoload_change_no_to_yes() { 460 add_option( 'foo', 'value1', '', 'no');461 update_option( 'foo', 'value2', 'yes');462 add_option( 'foo', 'value1', '', false ); 463 update_option( 'foo', 'value2', true ); 462 464 delete_option( 'foo' ); 463 465 $this->assertFalse( get_option( 'foo' ) ); … … 474 476 */ 475 477 public function test_update_option_with_autoload_change_yes_to_no() { 476 add_option( 'foo', 'value1', '', 'yes');477 update_option( 'foo', 'value2', 'no');478 add_option( 'foo', 'value1', '', true ); 479 update_option( 'foo', 'value2', false ); 478 480 delete_option( 'foo' ); 479 481 $this->assertFalse( get_option( 'foo' ) ); -
trunk/tests/phpunit/tests/option/updateOption.php
r55745 r58945 53 53 public function test_should_set_autoload_yes_for_nonexistent_option_when_autoload_param_is_yes() { 54 54 $this->flush_cache(); 55 update_option( 'test_update_option_default', 'value', 'yes');55 update_option( 'test_update_option_default', 'value', true ); 56 56 $this->flush_cache(); 57 57 … … 76 76 public function test_should_set_autoload_no_for_nonexistent_option_when_autoload_param_is_no() { 77 77 $this->flush_cache(); 78 update_option( 'test_update_option_default', 'value', 'no');78 update_option( 'test_update_option_default', 'value', false ); 79 79 $this->flush_cache(); 80 80 … … 123 123 */ 124 124 public function test_autoload_should_be_updated_for_existing_option_when_value_is_changed() { 125 add_option( 'foo', 'bar', '', 'no');125 add_option( 'foo', 'bar', '', false ); 126 126 $updated = update_option( 'foo', 'bar2', true ); 127 127 $this->assertTrue( $updated ); … … 147 147 */ 148 148 public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_unchanged() { 149 add_option( 'foo', 'bar', '', 'yes');149 add_option( 'foo', 'bar', '', true ); 150 150 $updated = update_option( 'foo', 'bar', false ); 151 151 $this->assertFalse( $updated ); … … 172 172 */ 173 173 public function test_autoload_should_not_be_updated_for_existing_option_when_value_is_changed_but_no_value_of_autoload_is_provided() { 174 add_option( 'foo', 'bar', '', 'yes');174 add_option( 'foo', 'bar', '', true ); 175 175 176 176 // Don't pass a value for `$autoload`. -
trunk/tests/phpunit/tests/option/wpLoadAlloptions.php
r57920 r58945 27 27 public function test_default_and_yes() { 28 28 add_option( 'foo', 'bar' ); 29 add_option( 'bar', 'foo', '', 'yes');29 add_option( 'bar', 'foo', '', true ); 30 30 $alloptions = wp_load_alloptions(); 31 31 $this->assertArrayHasKey( 'foo', $alloptions ); … … 40 40 public function test_default_and_no() { 41 41 add_option( 'foo', 'bar' ); 42 add_option( 'bar', 'foo', '', 'no');42 add_option( 'bar', 'foo', '', false ); 43 43 $alloptions = wp_load_alloptions(); 44 44 $this->assertArrayHasKey( 'foo', $alloptions ); -
trunk/tests/phpunit/tests/option/wpSetOptionAutoload.php
r57920 r58945 11 11 /** 12 12 * Tests that setting an option's autoload value to 'yes' works as expected. 13 * 14 * The values 'yes' and 'no' are only supported for backward compatibility. 13 15 * 14 16 * @ticket 58964 … … 30 32 /** 31 33 * Tests that setting an option's autoload value to 'no' works as expected. 34 * 35 * The values 'yes' and 'no' are only supported for backward compatibility. 32 36 * 33 37 * @ticket 58964 … … 57 61 $value = 'value'; 58 62 59 add_option( $option, $value, '', 'yes');63 add_option( $option, $value, '', true ); 60 64 61 $this->assertFalse( wp_set_option_autoload( $option, 'yes'), 'Function did unexpectedly succeed' );65 $this->assertFalse( wp_set_option_autoload( $option, true ), 'Function did unexpectedly succeed' ); 62 66 $this->assertSame( 'on', $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ), 'Option autoload value unexpectedly updated in database' ); 63 67 } … … 73 77 $option = 'test_option'; 74 78 75 $this->assertFalse( wp_set_option_autoload( $option, 'yes'), 'Function did unexpectedly succeed' );79 $this->assertFalse( wp_set_option_autoload( $option, true ), 'Function did unexpectedly succeed' ); 76 80 $this->assertNull( $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ), 'Missing option autoload value was set in database' ); 77 81 $this->assertArrayNotHasKey( $option, wp_cache_get( 'alloptions', 'options' ), 'Missing option found in alloptions cache' ); -
trunk/tests/phpunit/tests/option/wpSetOptionAutoloadValues.php
r57920 r58945 12 12 * Tests setting options' autoload to 'yes' where for some options this is already the case. 13 13 * 14 * The values 'yes' and 'no' are only supported for backward compatibility. 15 * 14 16 * @ticket 58964 15 17 */ … … 21 23 'test_option2' => 'yes', 22 24 ); 23 add_option( 'test_option1', 'value1', '', 'yes');24 add_option( 'test_option2', 'value2', '', 'no');25 add_option( 'test_option1', 'value1', '', true ); 26 add_option( 'test_option2', 'value2', '', false ); 25 27 $expected = array( 26 28 'test_option1' => false, … … 43 45 * In this case, the 'alloptions' cache should not be cleared, but only its options set to 'no' should be deleted. 44 46 * 47 * The values 'yes' and 'no' are only supported for backward compatibility. 48 * 45 49 * @ticket 58964 46 50 */ … … 52 56 'test_option2' => 'no', 53 57 ); 54 add_option( 'test_option1', 'value1', '', 'yes');55 add_option( 'test_option2', 'value2', '', 'no');58 add_option( 'test_option1', 'value1', '', true ); 59 add_option( 'test_option2', 'value2', '', false ); 56 60 $expected = array( 57 61 'test_option1' => true, … … 71 75 * Tests setting options' autoload to 'yes' where for all of them this is already the case. 72 76 * 77 * The values 'yes' and 'no' are only supported for backward compatibility. 78 * 73 79 * @ticket 58964 74 80 */ … … 80 86 'test_option2' => 'yes', 81 87 ); 82 add_option( 'test_option1', 'value1', '', 'yes');83 add_option( 'test_option2', 'value2', '', 'yes');88 add_option( 'test_option1', 'value1', '', true ); 89 add_option( 'test_option2', 'value2', '', true ); 84 90 $expected = array( 85 91 'test_option1' => false, … … 97 103 98 104 /** 99 * Tests setting options' autoload to either 'yes' or 'no'where for some options this is already the case.105 * Tests setting options' autoload to either true or false where for some options this is already the case. 100 106 * 101 107 * The test also covers one option that is entirely missing. … … 107 113 108 114 $options = array( 109 'test_option1' => 'yes',110 'test_option2' => 'no',111 'test_option3' => 'yes',112 'missing_opt' => 'yes',113 ); 114 add_option( 'test_option1', 'value1', '', 'no');115 add_option( 'test_option2', 'value2', '', 'yes');116 add_option( 'test_option3', 'value3', '', 'yes');115 'test_option1' => true, 116 'test_option2' => false, 117 'test_option3' => true, 118 'missing_opt' => true, 119 ); 120 add_option( 'test_option1', 'value1', '', false ); 121 add_option( 'test_option2', 'value2', '', true ); 122 add_option( 'test_option3', 'value3', '', true ); 117 123 $expected = array( 118 124 'test_option1' => true, … … 133 139 134 140 /** 135 * Tests setting options' autoload to either 'yes' or 'no' while only the 'no'options actually need to be updated.141 * Tests setting options' autoload to either true or false while only the false options actually need to be updated. 136 142 * 137 143 * In this case, the 'alloptions' cache should not be cleared, but only its options set to 'no' should be deleted. … … 143 149 144 150 $options = array( 145 'test_option1' => 'yes',146 'test_option2' => 'no',147 'test_option3' => 'yes',148 ); 149 add_option( 'test_option1', 'value1', '', 'yes');150 add_option( 'test_option2', 'value2', '', 'yes');151 add_option( 'test_option3', 'value3', '', 'yes');151 'test_option1' => true, 152 'test_option2' => false, 153 'test_option3' => true, 154 ); 155 add_option( 'test_option1', 'value1', '', true ); 156 add_option( 'test_option2', 'value2', '', true ); 157 add_option( 'test_option3', 'value3', '', true ); 152 158 $expected = array( 153 159 'test_option1' => false, … … 161 167 $this->assertSameSets( array( 'on', 'off', 'on' ), $wpdb->get_col( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name IN (" . implode( ',', array_fill( 0, count( $options ), '%s' ) ) . ')', ...array_keys( $options ) ) ), 'Option autoload values not updated in database' ); 162 168 foreach ( $options as $option => $autoload ) { 163 if ( 'no'=== $autoload ) {169 if ( false === $autoload ) { 164 170 $this->assertArrayNotHasKey( $option, wp_cache_get( 'alloptions', 'options' ), sprintf( 'Option %s not deleted from alloptions cache', $option ) ); 165 171 } else { … … 178 184 179 185 $options = array( 180 'test_option1' => 'yes',181 'test_option2' => 'yes',182 ); 183 add_option( 'test_option1', 'value1', '', 'no');184 add_option( 'test_option2', 'value2', '', 'no');186 'test_option1' => true, 187 'test_option2' => true, 188 ); 189 add_option( 'test_option1', 'value1', '', false ); 190 add_option( 'test_option2', 'value2', '', false ); 185 191 186 192 // Force UPDATE queries to fail, leading to no autoload values being updated. … … 204 210 205 211 /** 206 * Tests setting options' autoload with boolean values.212 * Tests setting options' autoload with now encouraged boolean values. 207 213 * 208 214 * @ticket 58964 -
trunk/tests/phpunit/tests/option/wpSetOptionsAutoload.php
r57920 r58945 12 12 * Tests that setting options' autoload value to 'yes' works as expected. 13 13 * 14 * The values 'yes' and 'no' are only supported for backward compatibility. 15 * 14 16 * @ticket 58964 15 17 */ … … 24 26 $expected = array(); 25 27 foreach ( $options as $option => $value ) { 26 add_option( $option, $value, '', 'no');28 add_option( $option, $value, '', false ); 27 29 $expected[ $option ] = true; 28 30 } … … 41 43 * Tests that setting options' autoload value to 'no' works as expected. 42 44 * 45 * The values 'yes' and 'no' are only supported for backward compatibility. 46 * 43 47 * @ticket 58964 44 48 */ … … 53 57 $expected = array(); 54 58 foreach ( $options as $option => $value ) { 55 add_option( $option, $value, '', 'yes');59 add_option( $option, $value, '', true ); 56 60 $expected[ $option ] = true; 57 61 } … … 81 85 $expected = array(); 82 86 foreach ( $options as $option => $value ) { 83 add_option( $option, $value, '', 'yes');87 add_option( $option, $value, '', true ); 84 88 $expected[ $option ] = false; 85 89 } 86 90 87 91 $num_queries = get_num_queries(); 88 $this->assertSame( $expected, wp_set_options_autoload( array_keys( $options ), 'yes'), 'Function did unexpectedly succeed' );92 $this->assertSame( $expected, wp_set_options_autoload( array_keys( $options ), true ), 'Function did unexpectedly succeed' ); 89 93 $this->assertSame( $num_queries + 1, get_num_queries(), 'Function attempted to update options autoload value in database' ); 90 94 $this->assertSame( array( 'on', 'on' ), $wpdb->get_col( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name IN (" . implode( ',', array_fill( 0, count( $options ), '%s' ) ) . ')', ...array_keys( $options ) ) ), 'Options autoload value unexpectedly updated in database' ); … … 109 113 } 110 114 111 $this->assertSame( $expected, wp_set_options_autoload( $options, 'yes'), 'Function did unexpectedly succeed' );115 $this->assertSame( $expected, wp_set_options_autoload( $options, true ), 'Function did unexpectedly succeed' ); 112 116 $this->assertSame( array(), $wpdb->get_col( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name IN (" . implode( ',', array_fill( 0, count( $options ), '%s' ) ) . ')', ...array_keys( $options ) ) ), 'Missing options autoload value was set in database' ); 113 117 } … … 126 130 ); 127 131 128 add_option( 'test_option1', $options['test_option1'], '', 'yes');129 add_option( 'test_option2', $options['test_option2'], '', 'no');132 add_option( 'test_option1', $options['test_option1'], '', true ); 133 add_option( 'test_option2', $options['test_option2'], '', false ); 130 134 $expected = array( 131 135 'test_option1' => false, … … 133 137 ); 134 138 135 $this->assertSame( $expected, wp_set_options_autoload( array_keys( $options ), 'yes'), 'Function produced unexpected result' );139 $this->assertSame( $expected, wp_set_options_autoload( array_keys( $options ), true ), 'Function produced unexpected result' ); 136 140 $this->assertSame( array( 'on', 'on' ), $wpdb->get_col( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name IN (" . implode( ',', array_fill( 0, count( $options ), '%s' ) ) . ')', ...array_keys( $options ) ) ), 'Option autoload values not updated in database' ); 137 141 foreach ( $options as $option => $value ) {
Note: See TracChangeset
for help on using the changeset viewer.