]> 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 b7128d08465a614da6ae7d162d7f628147066f4c..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,15 +112,17 @@ class ApiStatusesUpdateAction extends ApiAuthAction
             return;
         }
 
-        if (empty($_POST) && $_SERVER['CONTENT_LENGTH']) {
-            $this->clientError(sprintf(_('The server was unable to handle ' .
-                                         'that much POST data (%s bytes) due to its current configuration.'),
-                                       $_SERVER['CONTENT_LENGTH']));
-            return;
-        }
+        // Workaround for PHP returning empty $_POST and $_FILES when POST
+        // length > post_max_size in php.ini
 
-        if (empty($this->user)) {
-            $this->clientError(_('No such user!'), 404, $this->format);
+        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;
         }
 
@@ -133,6 +135,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction
             return;
         }
 
+        if (empty($this->user)) {
+            $this->clientError(_('No such user.'), 404, $this->format);
+            return;
+        }
+
         $status_shortened = common_shorten_links($this->status);
 
         if (Notice::contentTooLong($status_shortened)) {
@@ -193,26 +200,24 @@ class ApiStatusesUpdateAction extends ApiAuthAction
 
             $upload = null;
 
-            common_debug('looking for attachment');
-
-            $upload = MediaFile::fromUpload('media', $this->user);
-
-            common_debug("uploaded file = " . var_export($upload, true));
+            try {
+                $upload = MediaFile::fromUpload('media', $this->user);
+            } catch (ClientException $ce) {
+                $this->clientError($ce->getMessage());
+                return;
+            }
 
             if (isset($upload)) {
-                common_debug('newNotice: found an upload');
-
-                    $status_shortened .= ' ' . $upload->shortUrl();
+                $status_shortened .= ' ' . $upload->shortUrl();
 
-                    common_debug('content w/upload = ' . $status_shortened);
-
-                    if (Notice::contentTooLong($status_shortened)) {
-                        $upload->delete();
-                        $this->clientError(sprintf(_('Max notice size is %d chars, including attachment URL.'),
-                                                   Notice::maxContent()));
-                    } else {
-                        common_debug('content not too long');
-                    }
+                if (Notice::contentTooLong($status_shortened)) {
+                    $upload->delete();
+                    $msg = _(
+                        'Max notice size is %d chars, ' .
+                        'including attachment URL.'
+                    );
+                    $this->clientError(sprintf($msg, Notice::maxContent()));
+                }
             }
 
             $this->notice = Notice::saveNew(