]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apiaccountupdateprofileimage.php
Better workaround for PHP returning empty $_POST and $_FILES when
[quix0rs-gnu-social.git] / actions / apiaccountupdateprofileimage.php
index 416fee45acb0b608b3e2a10598f60ea1ddd2953b..72fb361bf8bcbdf183bb3e4f9304c4350d5d4d6d 100644 (file)
@@ -87,16 +87,22 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction
             return;
         }
 
-        if (empty($this->user)) {
-            $this->clientError(_('No such user!'), 404, $this->format);
+        // Workaround for PHP returning empty $_POST and $_FILES when POST
+        // length > post_max_size in php.ini
+
+        if (empty($_FILES)
+            && empty($_POST)
+            && ($_SERVER['CONTENT_LENGTH'] > 0)
+        ) {
+             $msg = _('The server was unable to handle that much POST ' .
+                    'data (%s bytes) due to its current configuration.');
+
+            $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
             return;
         }
 
-        // Workaround for PHP returning empty $_FILES when POST length > PHP settings
-
-        if (empty($_FILES) && ($_SERVER['CONTENT_LENGTH'] > 0)) {
-            common_debug('content-length = ' . $_SERVER['CONTENT_LENGTH']);
-            $this->clientError(_('Unable to handle that much POST data!'));
+        if (empty($this->user)) {
+            $this->clientError(_('No such user!'), 404, $this->format);
             return;
         }