Index: trunk/phase3/includes/api/ApiPageSet.php |
— | — | @@ -447,6 +447,10 @@ |
448 | 448 | } |
449 | 449 | |
450 | 450 | $pageids = array_map( 'intval', $pageids ); // paranoia |
| 451 | + $remaining = array_flip( $pageids ); |
| 452 | + |
| 453 | + $pageids = self::getPositiveIntegers( $pageids ); |
| 454 | + |
451 | 455 | $set = array( |
452 | 456 | 'page_id' => $pageids |
453 | 457 | ); |
— | — | @@ -458,7 +462,6 @@ |
459 | 463 | __METHOD__ ); |
460 | 464 | $this->profileDBOut(); |
461 | 465 | |
462 | | - $remaining = array_flip( $pageids ); |
463 | 466 | $this->initFromQueryResult( $res, $remaining, false ); // process PageIDs |
464 | 467 | |
465 | 468 | // Resolve any found redirects |
— | — | @@ -535,14 +538,7 @@ |
536 | 539 | $pageids = array(); |
537 | 540 | $remaining = array_flip( $revids ); |
538 | 541 | |
539 | | - // bug 25734 API: possible issue with revids validation |
540 | | - // It seems with a load of revision rows, MySQL gets upset |
541 | | - // Remove any < 0 revids, as they can't be valid |
542 | | - foreach( $revids as $i => $revid ) { |
543 | | - if ( $revid < 0 ) { |
544 | | - unset( $revids[$i] ); |
545 | | - } |
546 | | - } |
| 542 | + $revids = self::getPositiveIntegers( $revids ); |
547 | 543 | |
548 | 544 | $tables = array( 'revision', 'page' ); |
549 | 545 | $fields = array( 'rev_id', 'rev_page' ); |
— | — | @@ -721,6 +717,25 @@ |
722 | 718 | return $linkBatch; |
723 | 719 | } |
724 | 720 | |
| 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 | + |
725 | 740 | protected function getAllowedParams() { |
726 | 741 | return array( |
727 | 742 | 'titles' => array( |