From b522c401e66e5b5d7e000c1bf25fd4b4a4d0558f Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 6 Nov 2009 17:21:08 -0800 Subject: Better workaround for PHP returning empty $_POST and $_FILES when POST length > post_max_size in php.ini. I also added this check to avatar upload, which was failing with huge files. --- actions/apistatusesupdate.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'actions/apistatusesupdate.php') diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 82fe5a537..e369fa71e 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -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.', @@ -126,13 +140,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction return; } - // Workaround for PHP returning empty $_FILES when POST length > PHP settings - - if (empty($_FILES) && ($_SERVER['CONTENT_LENGTH'] > 0)) { - $this->clientError(_('Unable to handle that much POST data!')); - return; - } - $status_shortened = common_shorten_links($this->status); if (Notice::contentTooLong($status_shortened)) { -- cgit v1.2.3-54-g00ecf