From d9edf86faf1f749e45dcf567acf5b9afa2b70d40 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sat, 10 Oct 2015 23:14:11 +0000 Subject: [PATCH] MS: Allow for a `blog_upload_space` setting of 0 to restrict uploads. Previously, an value matching `empty()` would have been bypassed in favor of the default setting for 100MB. Related #19538, r19639, r19652, where we saw the bug, fixed the bug, and then unfixed the bug so that it was not a surprise in a point release. See #34037. git-svn-id: https://develop.svn.wordpress.org/trunk@35016 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-functions.php | 2 +- tests/phpunit/tests/multisite/getSpaceAllowed.php | 8 ++++---- tests/phpunit/tests/multisite/isUploadSpaceAvailable.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index 49f55cfa8d..dc92eb3cbd 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -2296,7 +2296,7 @@ function get_space_allowed() { if ( ! is_numeric( $space_allowed ) ) $space_allowed = get_site_option( 'blog_upload_space' ); - if ( empty( $space_allowed ) || ! is_numeric( $space_allowed ) ) + if ( ! is_numeric( $space_allowed ) ) $space_allowed = 100; /** diff --git a/tests/phpunit/tests/multisite/getSpaceAllowed.php b/tests/phpunit/tests/multisite/getSpaceAllowed.php index 069201ad85..6470f38592 100644 --- a/tests/phpunit/tests/multisite/getSpaceAllowed.php +++ b/tests/phpunit/tests/multisite/getSpaceAllowed.php @@ -94,10 +94,10 @@ class Tests_Multisite_Get_Space_Allowed extends WP_UnitTestCase { array( false, false, 100 ), array( 'NAN', 'NAN', 100 ), - // These are likely unexpected. - array( 0, 666, 100 ), - array( false, 0, 100 ), - array( 'NAN', 0, 100 ), + // These effectively disable uploads. + array( 0, 666, 0 ), + array( false, 0, 0 ), + array( 'NAN', 0, 0 ), ); } diff --git a/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php b/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php index 36be275944..d2abfd2337 100644 --- a/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php +++ b/tests/phpunit/tests/multisite/isUploadSpaceAvailable.php @@ -102,7 +102,7 @@ class Tests_Multisite_Is_Upload_Space_Available extends WP_UnitTestCase { $available = is_upload_space_available(); remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used_small' ) ); - $this->assertTrue( $available ); + $this->assertFalse( $available ); } function test_is_upload_space_available_upload_space_negative() {