From 591b743362bb42245b84ec6c413834b6f58746b9 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 26 Sep 2015 19:48:57 +0000 Subject: [PATCH] After [34577], alter `wp_xmlrpc_server::mw_newMediaObject()` to check upload space in multisite. See #21292. git-svn-id: https://develop.svn.wordpress.org/trunk@34603 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-xmlrpc-server.php | 5 +++++ src/wp-includes/ms-functions.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index 48422c6a92..8661a44b4c 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -5721,6 +5721,11 @@ class wp_xmlrpc_server extends IXR_Server { return $this->error; } + if ( is_multisite() && upload_is_user_over_quota( false ) ) { + $this->error = new IXR_Error( 401, __( 'Sorry, you have used your space allocation.' ) ); + return $this->error; + } + /** * Filter whether to preempt the XML-RPC media upload. * diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index e866e6e255..1fc709541c 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -2372,7 +2372,11 @@ function get_space_allowed() { * @return int of upload space available in bytes */ function get_upload_space_available() { - $space_allowed = get_space_allowed() * 1024 * 1024; + $allowed = get_space_allowed(); + if ( $allowed < 0 ) { + $allowed = 0; + } + $space_allowed = $allowed * 1024 * 1024; if ( get_site_option( 'upload_space_check_disabled' ) ) return $space_allowed;