Changeset 54482
- Timestamp:
- 10/11/2022 03:05:29 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r54474 r54482 4772 4772 case 'start_of_week': 4773 4773 case 'site_icon': 4774 case 'fileupload_maxk': 4774 4775 $value = absint( $value ); 4775 4776 break; -
trunk/src/wp-includes/ms-functions.php
r54240 r54482 2616 2616 */ 2617 2617 function upload_size_limit_filter( $size ) { 2618 $fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ); 2618 $fileupload_maxk = (int) get_site_option( 'fileupload_maxk', 1500 ); 2619 $max_fileupload_in_bytes = KB_IN_BYTES * $fileupload_maxk; 2620 2619 2621 if ( get_site_option( 'upload_space_check_disabled' ) ) { 2620 return min( $size, $ fileupload_maxk);2621 } 2622 2623 return min( $size, $ fileupload_maxk, get_upload_space_available() );2622 return min( $size, $max_fileupload_in_bytes ); 2623 } 2624 2625 return min( $size, $max_fileupload_in_bytes, get_upload_space_available() ); 2624 2626 } 2625 2627 -
trunk/tests/phpunit/tests/multisite/network.php
r54402 r54482 397 397 398 398 /** 399 * Test the default behavior of upload_size_limit_filter. 400 * If any default option is changed, the function returns the min value between the 401 * parameter passed and the `fileupload_maxk` site option (1500Kb by default) 402 * 403 * @ticket 55926 404 */ 405 public function test_upload_size_limit_filter() { 406 $return = upload_size_limit_filter( 1499 * KB_IN_BYTES ); 407 $this->assertSame( 1499 * KB_IN_BYTES, $return ); 408 $return = upload_size_limit_filter( 1501 * KB_IN_BYTES ); 409 $this->assertSame( 1500 * KB_IN_BYTES, $return ); 410 } 411 412 /** 413 * Test if upload_size_limit_filter behaves as expected when the `fileupload_maxk` is 0 or an empty string. 414 * 415 * @ticket 55926 416 * @dataProvider data_upload_size_limit_filter_empty_fileupload_maxk 417 */ 418 public function test_upload_size_limit_filter_empty_fileupload_maxk( $callable_set_fileupload_maxk ) { 419 add_filter( 'site_option_fileupload_maxk', $callable_set_fileupload_maxk ); 420 $return = upload_size_limit_filter( 1500 ); 421 $this->assertSame( 0, $return ); 422 } 423 424 /** 425 * @ticket 55926 426 */ 427 public function data_upload_size_limit_filter_empty_fileupload_maxk() { 428 return array( 429 array( '__return_zero' ), 430 array( '__return_empty_string' ), 431 ); 432 } 433 434 /** 435 * When upload_space_check is enabled, the space allowed is also considered by `upload_size_limit_filter`. 436 * 437 * @ticket 55926 438 */ 439 public function test_upload_size_limit_filter_when_upload_space_check_enabled() { 440 add_filter( 'get_space_allowed', '__return_zero' ); 441 add_filter( 'site_option_upload_space_check_disabled', '__return_false' ); 442 $return = upload_size_limit_filter( 100 ); 443 $this->assertSame( 0, $return ); 444 } 445 446 /** 399 447 * @ticket 40489 400 448 * @dataProvider data_wp_is_large_network
Note: See TracChangeset
for help on using the changeset viewer.