From d5e572f992d4d41c0269131346dc8c1f4351a650 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sat, 10 Oct 2015 23:17:01 +0000 Subject: [PATCH] MS: Handle the possibility of 0 when checking a user's upload quota. Upload space of 0 is now more possible via r35016 and should be respected rather than modified to a default of 10MB. Fixes #34037. git-svn-id: https://develop.svn.wordpress.org/trunk@35017 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/ms.php | 4 ++-- tests/phpunit/tests/multisite/uploadIsUserOverQuota.php | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/wp-admin/includes/ms.php b/src/wp-admin/includes/ms.php index 6125ac116e..f1eb8531dc 100644 --- a/src/wp-admin/includes/ms.php +++ b/src/wp-admin/includes/ms.php @@ -417,9 +417,9 @@ function upload_is_user_over_quota( $echo = true ) { return false; $space_allowed = get_space_allowed(); - if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) ) + if ( ! is_numeric( $space_allowed ) ) { $space_allowed = 10; // Default space allowed is 10 MB - + } $space_used = get_space_used(); if ( ( $space_allowed - $space_used ) < 0 ) { diff --git a/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php b/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php index 22c3d2553e..73e432c9ca 100644 --- a/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php +++ b/tests/phpunit/tests/multisite/uploadIsUserOverQuota.php @@ -27,12 +27,6 @@ class Tests_Multisite_Upload_Is_User_Over_Quota extends WP_UnitTestCase { parent::tearDown(); } - /** - * In this scenario, 10 is set as the spaced allowed when 0 is returned - * by `get_space_allowed()` inside `upload_is_user_over_quota()`. - * - * This is likely not expected behavior. - */ public function test_upload_is_user_over_quota_allowed_0_used_5() { add_filter( 'get_space_allowed', '__return_zero' ); add_filter( 'pre_get_space_used', array( $this, '_filter_space_5' ) ); @@ -40,7 +34,7 @@ class Tests_Multisite_Upload_Is_User_Over_Quota extends WP_UnitTestCase { remove_filter( 'get_space_allowed', '__return_zero' ); remove_filter( 'pre_get_space_used', array( $this, '_filter_space_5' ) ); - $this->assertFalse( $result ); + $this->assertTrue( $result ); } public function test_upload_is_user_over_quota_allowed_0_used_0() {