r89514 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89513‎ | r89514 | r89515 >
Date:18:05, 5 June 2011
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.17wmf1/includes (modified) (history)
  • /branches/wmf/1.17wmf1/includes/api (modified) (history)
  • /branches/wmf/1.17wmf1/includes/api/ApiPageSet.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/includes/api/ApiPageSet.php
@@ -446,6 +446,10 @@
447447 }
448448
449449 $pageids = array_map( 'intval', $pageids ); // paranoia
 450+ $remaining = array_flip( $pageids );
 451+
 452+ $pageids = self::getPositiveIntegers( $pageids );
 453+
450454 $set = array(
451455 'page_id' => $pageids
452456 );
@@ -457,7 +461,6 @@
458462 __METHOD__ );
459463 $this->profileDBOut();
460464
461 - $remaining = array_flip( $pageids );
462465 $this->initFromQueryResult( $db, $res, $remaining, false ); // process PageIDs
463466
464467 // Resolve any found redirects
@@ -535,6 +538,8 @@
536539 $pageids = array();
537540 $remaining = array_flip( $revids );
538541
 542+ $revids = self::getPositiveIntegers( $revids );
 543+
539544 $tables = array( 'revision', 'page' );
540545 $fields = array( 'rev_id', 'rev_page' );
541546 $where = array( 'rev_id' => $revids, 'rev_page = page_id' );
@@ -712,6 +717,25 @@
713718 return $linkBatch;
714719 }
715720
 721+ /**
 722+ * Returns the input array of integers with all values < 0 removed
 723+ *
 724+ * @param $array array
 725+ * @return array
 726+ */
 727+ private static function getPositiveIntegers( $array ) {
 728+ // bug 25734 API: possible issue with revids validation
 729+ // It seems with a load of revision rows, MySQL gets upset
 730+ // Remove any < 0 integers, as they can't be valid
 731+ foreach( $array as $i => $int ) {
 732+ if ( $int < 0 ) {
 733+ unset( $array[$i] );
 734+ }
 735+ }
 736+
 737+ return $array;
 738+ }
 739+
716740 protected function getAllowedParams() {
717741 return array(
718742 'titles' => array(
Property changes on: branches/wmf/1.17wmf1/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
719743 Merged /trunk/phase3/includes/api:r89512-89513
Property changes on: branches/wmf/1.17wmf1/includes
___________________________________________________________________
Modified: svn:mergeinfo
720744 Merged /trunk/phase3/includes:r89512-89513

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89512* (bug 25734) API: possible issue with revids validation...reedy17:49, 5 June 2011
r89513Followup r89512...reedy18:01, 5 June 2011

Status & tagging log