Patch from MaxSem re bug 15162 - handle throttling in the login API
[lhc/web/wiklou.git] / includes / api / ApiBase.php
index cd4fa1a..9f66869 100644 (file)
@@ -515,10 +515,12 @@ abstract class ApiBase {
        protected function parseMultiValue($valueName, $value, $allowMultiple, $allowedValues) {
                if( trim($value) === "" )
                        return array();
-               $sizeLimit = $this->mMainModule->canApiHighLimits() ? 501 : 51;
-               $valuesList = explode('|', $value,$sizeLimit);
-               if( count($valuesList) == $sizeLimit ) {
+               $sizeLimit = $this->mMainModule->canApiHighLimits() ? self::LIMIT_SML2 : self::LIMIT_SML1;
+               $valuesList = explode('|', $value, $sizeLimit + 1);
+               if( count($valuesList) == $sizeLimit + 1 ) {
                        $junk = array_pop($valuesList); // kill last jumbled param
+                       // Set a warning too
+                       $this->setWarning("Too many values supplied for parameter '$valueName': the limit is $sizeLimit");
                }
                if (!$allowMultiple && count($valuesList) != 1) {
                        $possibleValues = is_array($allowedValues) ? "of '" . implode("', '", $allowedValues) . "'" : '';
@@ -594,8 +596,6 @@ abstract class ApiBase {
                'protectedpagetext' => array('code' => 'protectedpage', 'info' => "The ``\$1'' right is required to edit this page"),
                'protect-cantedit' => array('code' => 'cantedit', 'info' => "You can't protect this page because you can't edit it"),
                'badaccess-group0' => array('code' => 'permissiondenied', 'info' => "Permission denied"), // Generic permission denied message
-               'badaccess-group1' => array('code' => 'permissiondenied', 'info' => "Permission denied"), // Can't use the parameter 'cause it's wikilinked
-               'badaccess-group2' => array('code' => 'permissiondenied', 'info' => "Permission denied"),
                'badaccess-groups' => array('code' => 'permissiondenied', 'info' => "Permission denied"),
                'titleprotected' => array('code' => 'protectedtitle', 'info' => "This title has been protected from creation"),
                'nocreate-loggedin' => array('code' => 'cantcreate', 'info' => "You don't have permission to create new pages"),
@@ -650,6 +650,7 @@ abstract class ApiBase {
                'cannotundelete' => array('code' => 'cantundelete', 'info' => "Couldn't undelete: the requested revisions may not exist, or may have been undeleted already"),
                'permdenied-undelete' => array('code' => 'permissiondenied', 'info' => "You don't have permission to restore deleted revisions"),
                'createonly-exists' => array('code' => 'articleexists', 'info' => "The article you tried to create has been created already"),
+               'nocreate-missing' => array('code' => 'missingtitle', 'info' => "The article you tried to edit doesn't exist"),
 
                // ApiEditPage messages
                'noimageredirect-anon' => array('code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects"),
@@ -662,6 +663,8 @@ abstract class ApiBase {
                'wasdeleted' => array('code' => 'pagedeleted', 'info' => "The page has been deleted since you fetched its timestamp"),
                'blankpage' => array('code' => 'emptypage', 'info' => "Creating new, empty pages is not allowed"),
                'editconflict' => array('code' => 'editconflict', 'info' => "Edit conflict detected"),
+               'hashcheckfailed' => array('code' => 'badmd5', 'info' => "The supplied MD5 hash was incorrect"),
+               'missingtext' => array('code' => 'notext', 'info' => "One of the text, appendtext and prependtext parameters must be set"),
        );
 
        /**