]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apistatusesupdate.php
Localisation updates from translatewiki.net
[quix0rs-gnu-social.git] / actions / apistatusesupdate.php
index 3a030f0fe851423bd04211a157302aa9668f03e4..5c23acccae7958e01d71395fceafc6d85b5e27dc 100644 (file)
@@ -80,7 +80,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
         $this->status = $this->trimmed('status');
         $this->source = $this->trimmed('source');
 
-        if (empty($this->source) || in_array($source, $this->reserved_sources)) {
+        if (empty($this->source) || in_array($source, self::$reserved_sources)) {
             $this->source = 'api';
         }
 
@@ -112,6 +112,20 @@ class ApiStatusesUpdateAction extends ApiAuthAction
             return;
         }
 
+        // 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;
+        }
+
         if (empty($this->status)) {
             $this->clientError(
                 'Client must provide a \'status\' parameter with a value.',
@@ -122,14 +136,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
         }
 
         if (empty($this->user)) {
-            $this->clientError(_('No such user!'), 404, $this->format);
-            return;
-        }
-
-        // Workaround for PHP returning empty $_FILES when POST length > PHP settings
-
-        if (empty($_POST) && ($_SERVER['CONTENT_LENGTH'] > 0)) {
-            $this->clientError(_('Unable to handle that much POST data!'));
+            $this->clientError(_('No such user.'), 404, $this->format);
             return;
         }
 
@@ -192,7 +199,13 @@ class ApiStatusesUpdateAction extends ApiAuthAction
             }
 
             $upload = null;
-            $upload = MediaFile::fromUpload('media', $this->user);
+
+            try {
+                $upload = MediaFile::fromUpload('media', $this->user);
+            } catch (ClientException $ce) {
+                $this->clientError($ce->getMessage());
+                return;
+            }
 
             if (isset($upload)) {
                 $status_shortened .= ' ' . $upload->shortUrl();