From: Sam Reed Date: Sun, 5 Jun 2011 18:01:30 +0000 (+0000) Subject: Followup r89512 X-Git-Tag: 1.31.0-rc.0~29703 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=b92b33792c79e855afae2ca1e80ae3a8a6b7bdb1;p=lhc%2Fweb%2Fwiklou.git Followup r89512 Apply the same positive integer validation to pageids (as the same behaviour can occur) Refactor out common code, and reorganise initFromPageIds code to be similar to that of initFromRevIDs --- diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index cfee7a4225..862468d937 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -447,6 +447,10 @@ class ApiPageSet extends ApiQueryBase { } $pageids = array_map( 'intval', $pageids ); // paranoia + $remaining = array_flip( $pageids ); + + $pageids = self::getPositiveIntegers( $pageids ); + $set = array( 'page_id' => $pageids ); @@ -458,7 +462,6 @@ class ApiPageSet extends ApiQueryBase { __METHOD__ ); $this->profileDBOut(); - $remaining = array_flip( $pageids ); $this->initFromQueryResult( $res, $remaining, false ); // process PageIDs // Resolve any found redirects @@ -535,14 +538,7 @@ class ApiPageSet extends ApiQueryBase { $pageids = array(); $remaining = array_flip( $revids ); - // bug 25734 API: possible issue with revids validation - // It seems with a load of revision rows, MySQL gets upset - // Remove any < 0 revids, as they can't be valid - foreach( $revids as $i => $revid ) { - if ( $revid < 0 ) { - unset( $revids[$i] ); - } - } + $revids = self::getPositiveIntegers( $revids ); $tables = array( 'revision', 'page' ); $fields = array( 'rev_id', 'rev_page' ); @@ -721,6 +717,25 @@ class ApiPageSet extends ApiQueryBase { return $linkBatch; } + /** + * Returns the input array of integers with all values < 0 removed + * + * @param $array array + * @return array + */ + private static function getPositiveIntegers( $array ) { + // bug 25734 API: possible issue with revids validation + // It seems with a load of revision rows, MySQL gets upset + // Remove any < 0 integers, as they can't be valid + foreach( $array as $i => $int ) { + if ( $int < 0 ) { + unset( $array[$i] ); + } + } + + return $array; + } + protected function getAllowedParams() { return array( 'titles' => array(