http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89513
Revision: 89513
Author: reedy
Date: 2011-06-05 18:01:30 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
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
Modified Paths:
--------------
trunk/phase3/includes/api/ApiPageSet.php
Modified: trunk/phase3/includes/api/ApiPageSet.php
===================================================================
--- trunk/phase3/includes/api/ApiPageSet.php 2011-06-05 17:49:00 UTC (rev
89512)
+++ trunk/phase3/includes/api/ApiPageSet.php 2011-06-05 18:01:30 UTC (rev
89513)
@@ -447,6 +447,10 @@
}
$pageids = array_map( 'intval', $pageids ); // paranoia
+ $remaining = array_flip( $pageids );
+
+ $pageids = self::getPositiveIntegers( $pageids );
+
$set = array(
'page_id' => $pageids
);
@@ -458,7 +462,6 @@
__METHOD__ );
$this->profileDBOut();
- $remaining = array_flip( $pageids );
$this->initFromQueryResult( $res, $remaining, false ); //
process PageIDs
// Resolve any found redirects
@@ -535,14 +538,7 @@
$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 @@
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(
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs