Changeset 58811
- Timestamp:
- 07/25/2024 11:02:47 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r58782 r58811 2265 2265 ) 2266 2266 ); 2267 2268 if ( $result ) { 2269 $notoptions_key = "$network_id:notoptions"; 2270 $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); 2271 2272 if ( ! is_array( $notoptions ) ) { 2273 $notoptions = array(); 2274 } 2275 $notoptions[ $option ] = true; 2276 wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); 2277 } 2267 2278 } 2268 2279 … … 2293 2304 */ 2294 2305 do_action( 'delete_site_option', $option, $network_id ); 2295 2296 $notoptions_key = "$network_id:notoptions";2297 $notoptions = wp_cache_get( $notoptions_key, 'site-options' );2298 2299 if ( ! is_array( $notoptions ) ) {2300 $notoptions = array();2301 }2302 $notoptions[ $option ] = true;2303 wp_cache_set( $notoptions_key, $notoptions, 'site-options' );2304 2306 2305 2307 return true; -
trunk/tests/phpunit/tests/option/networkOption.php
r58782 r58811 61 61 * 62 62 * @ticket 61484 63 * @ticket 61730 63 64 * 64 65 * @covers ::delete_network_option … … 73 74 $this->assertIsArray( $notoptions, 'The notoptions cache is expected to be an array.' ); 74 75 $this->assertTrue( $notoptions['foo'], 'The deleted options is expected to be in notoptions.' ); 76 77 if ( ! is_multisite() ) { 78 $network_notoptions = wp_cache_get( '1:notoptions', 'site-options' ); 79 $this->assertTrue( empty( $network_notoptions['foo'] ), 'The deleted option is not expected to be in network notoptions on a non-multisite.' ); 80 } 75 81 76 82 $before = get_num_queries(); … … 303 309 $this->assertArrayNotHasKey( $option_name, $updated_notoptions, 'The "foobar" option should not be in the notoptions cache after updating it.' ); 304 310 } 311 312 /** 313 * Test adding a previously known notoption returns the correct value. 314 * 315 * @ticket 61730 316 * 317 * @covers ::add_network_option 318 * @covers ::delete_network_option 319 */ 320 public function test_adding_previous_notoption_returns_correct_value() { 321 $option_name = 'ticket_61730_option_to_be_created'; 322 323 add_network_option( 1, $option_name, 'baz' ); 324 delete_network_option( 1, $option_name ); 325 326 $this->assertFalse( get_network_option( 1, $option_name ), 'The option should not be found.' ); 327 328 add_network_option( 1, $option_name, 'foo' ); 329 $this->assertSame( 'foo', get_network_option( 1, $option_name ), 'The option should return the newly set value.' ); 330 } 331 332 /** 333 * Test `get_network_option()` does not use network notoptions cache for single sites. 334 * 335 * @ticket 61730 336 * 337 * @group ms-excluded 338 * 339 * @covers ::get_network_option 340 */ 341 public function test_get_network_option_does_not_use_network_notoptions_cache_for_single_sites() { 342 get_network_option( 1, 'ticket_61730_notoption' ); 343 344 $network_notoptions_cache = wp_cache_get( '1:notoptions', 'site-options' ); 345 $single_site_notoptions_cache = wp_cache_get( 'notoptions', 'options' ); 346 347 $this->assertEmpty( $network_notoptions_cache, 'Network notoptions cache should not be set for single site installs.' ); 348 $this->assertIsArray( $single_site_notoptions_cache, 'Single site notoptions cache should be set.' ); 349 $this->assertArrayHasKey( 'ticket_61730_notoption', $single_site_notoptions_cache, 'The option should be in the notoptions cache.' ); 350 } 351 352 /** 353 * Test `delete_network_option()` does not use network notoptions cache for single sites. 354 * 355 * @ticket 61730 356 * @ticket 61484 357 * 358 * @group ms-excluded 359 * 360 * @covers ::delete_network_option 361 */ 362 public function test_delete_network_option_does_not_use_network_notoptions_cache_for_single_sites() { 363 add_network_option( 1, 'ticket_61730_notoption', 'value' ); 364 delete_network_option( 1, 'ticket_61730_notoption' ); 365 366 $network_notoptions_cache = wp_cache_get( '1:notoptions', 'site-options' ); 367 $single_site_notoptions_cache = wp_cache_get( 'notoptions', 'options' ); 368 369 $this->assertEmpty( $network_notoptions_cache, 'Network notoptions cache should not be set for single site installs.' ); 370 $this->assertIsArray( $single_site_notoptions_cache, 'Single site notoptions cache should be set.' ); 371 $this->assertArrayHasKey( 'ticket_61730_notoption', $single_site_notoptions_cache, 'The option should be in the notoptions cache.' ); 372 } 373 374 /** 375 * Test `get_network_option()` does not use single site notoptions cache for networks. 376 * 377 * @ticket 61730 378 * 379 * @group ms-required 380 * 381 * @covers ::get_network_option 382 */ 383 public function test_get_network_option_does_not_use_single_site_notoptions_cache_for_networks() { 384 get_network_option( 1, 'ticket_61730_notoption' ); 385 386 $network_notoptions_cache = wp_cache_get( '1:notoptions', 'site-options' ); 387 $single_site_notoptions_cache = wp_cache_get( 'notoptions', 'options' ); 388 389 $this->assertEmpty( $single_site_notoptions_cache, 'Single site notoptions cache should not be set for multisite installs.' ); 390 $this->assertIsArray( $network_notoptions_cache, 'Multisite notoptions cache should be set.' ); 391 $this->assertArrayHasKey( 'ticket_61730_notoption', $network_notoptions_cache, 'The option should be in the notoptions cache.' ); 392 } 393 394 /** 395 * Test `delete_network_option()` does not use single site notoptions cache for networks. 396 * 397 * @ticket 61730 398 * @ticket 61484 399 * 400 * @group ms-required 401 * 402 * @covers ::delete_network_option 403 */ 404 public function test_delete_network_option_does_not_use_single_site_notoptions_cache_for_networks() { 405 add_network_option( 1, 'ticket_61730_notoption', 'value' ); 406 delete_network_option( 1, 'ticket_61730_notoption' ); 407 408 $network_notoptions_cache = wp_cache_get( '1:notoptions', 'site-options' ); 409 $single_site_notoptions_cache = wp_cache_get( 'notoptions', 'options' ); 410 411 $this->assertEmpty( $single_site_notoptions_cache, 'Single site notoptions cache should not be set for multisite installs.' ); 412 $this->assertIsArray( $network_notoptions_cache, 'Multisite notoptions cache should be set.' ); 413 $this->assertArrayHasKey( 'ticket_61730_notoption', $network_notoptions_cache, 'The option should be in the notoptions cache.' ); 414 } 305 415 }
Note: See TracChangeset
for help on using the changeset viewer.