return array();
$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
+ if( self::truncateArray($valuesList, $sizeLimit) ) {
$this->setWarning("Too many values supplied for parameter '$valueName': the limit is $sizeLimit");
}
if (!$allowMultiple && count($valuesList) != 1) {
}
}
}
+
+ /**
+ * Truncate an array to a certain length.
+ * @param $arr array Array to truncate
+ * @param $limit int Maximum length
+ * @return bool True if the array was truncated, false otherwise
+ */
+ public static function truncateArray(&$arr, $limit)
+ {
+ $modified = false;
+ while(count($arr) > $limit)
+ {
+ $junk = array_pop($arr);
+ $modified = true;
+ }
+ return $modified;
+ }
/**
* Call main module's error handler
}
}
elseif ($revCount > 0) {
- $this->validateLimit('rev_count', $revCount, 1, $userMax, $botMax);
+ $max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
+ $revs = $pageSet->getRevisionIDs();
+ if(self::truncateArray($revs, $max))
+ $this->setWarning("Too many values supplied for parameter 'revids': the limit is $max");
// Get all revision IDs
- $this->addWhereFld('rev_id', array_keys($pageSet->getRevisionIDs()));
+ $this->addWhereFld('rev_id', array_keys($revs));
// assumption testing -- we should never get more then $revCount rows.
$limit = $revCount;
}
elseif ($pageCount > 0) {
+ $max = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
+ $titles = $pageSet->getGoodTitles();
+ if(self::truncateArray($titles, $max))
+ $this->setWarning("Too many values supplied for parameter 'titles': the limit is $max");
+
// When working in multi-page non-enumeration mode,
// limit to the latest revision only
$this->addWhere('page_id=rev_page');
$this->addWhere('page_latest=rev_id');
- $this->validateLimit('page_count', $pageCount, 1, $userMax, $botMax);
-
+
// Get all page IDs
- $this->addWhereFld('page_id', array_keys($pageSet->getGoodTitles()));
+ $this->addWhereFld('page_id', array_keys($titles));
// assumption testing -- we should never get more then $pageCount rows.
$limit = $pageCount;