Ticket #31119: 31119.patch
| File 31119.patch, 2.4 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/option.php
346 346 * @param string $option Name of option to add. Expected to not be SQL-escaped. 347 347 * @param mixed $value Optional. Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped. 348 348 * @param string $deprecated Optional. Description. Not used anymore. 349 * @param string|bool $autoload Optional. Default is enabled. Whether to load the option when WordPress starts up. 349 * @param string|bool $autoload Optional. Whether to load the option when WordPress starts up. 350 * Default is enabled. Accepts "no" or false to disable. 350 351 * @return bool False if option was not added and true if option was added. 351 352 */ 352 353 function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) { … … 373 374 return false; 374 375 375 376 $serialized_value = maybe_serialize( $value ); 376 $autoload = ( 'no' === $autoload ) ? 'no' : 'yes';377 $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; 377 378 378 379 /** 379 380 * Fires before an option is added. -
tests/phpunit/tests/option/option.php
99 99 function test_special_option_name_notoptions() { 100 100 delete_option( 'notoptions' ); 101 101 } 102 103 /** 104 * Options should be autoloaded unless they were added with "no" or `false`. 105 */ 106 function test_option_autoloading() { 107 global $wpdb; 108 109 $options = array( 110 'autoload_yes' => 'yes', 111 'autoload_true' => true, 112 'autoload_no' => 'no', 113 'autoload_false' => false, 114 'autoload_string' => rand_str(), 115 'autoload_int' => 123456, 116 'autoload_array' => array(), 117 ); 118 119 foreach ( $options as $name => $autoload ) { 120 add_option( $name, rand_str(), '', $autoload ); 121 $actual = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s LIMIT 1", $name ) ); 122 if ( 'no' === $autoload || false === $autoload ) { 123 $this->assertEquals( 'no', $actual->autoload, $name ); 124 } else { 125 $this->assertEquals( 'yes', $actual->autoload, $name ); 126 } 127 } 128 } 102 129 }