r89646 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89645‎ | r89646 | r89647 >
Date:14:04, 7 June 2011
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /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
@@ -450,17 +450,20 @@
451451
452452 $pageids = self::getPositiveIntegers( $pageids );
453453
454 - $set = array(
455 - 'page_id' => $pageids
456 - );
457 - $db = $this->getDB();
 454+ $res = null;
 455+ if ( count( $pageids ) ) {
 456+ $set = array(
 457+ 'page_id' => $pageids
 458+ );
 459+ $db = $this->getDB();
458460
459 - // Get pageIDs data from the `page` table
460 - $this->profileDBIn();
461 - $res = $db->select( 'page', $this->getPageTableFields(), $set,
462 - __METHOD__ );
463 - $this->profileDBOut();
464 -
 461+ // Get pageIDs data from the `page` table
 462+ $this->profileDBIn();
 463+ $res = $db->select( 'page', $this->getPageTableFields(), $set,
 464+ __METHOD__ );
 465+ $this->profileDBOut();
 466+ }
 467+
465468 $this->initFromQueryResult( $db, $res, $remaining, false ); // process PageIDs
466469
467470 // Resolve any found redirects
@@ -483,20 +486,22 @@
484487 ApiBase::dieDebug( __METHOD__, 'Missing $processTitles parameter when $remaining is provided' );
485488 }
486489
487 - foreach ( $res as $row ) {
488 - $pageId = intval( $row->page_id );
 490+ if ( $res ) {
 491+ foreach ( $res as $row ) {
 492+ $pageId = intval( $row->page_id );
489493
490 - // Remove found page from the list of remaining items
491 - if ( isset( $remaining ) ) {
492 - if ( $processTitles ) {
493 - unset( $remaining[$row->page_namespace][$row->page_title] );
494 - } else {
495 - unset( $remaining[$pageId] );
 494+ // Remove found page from the list of remaining items
 495+ if ( isset( $remaining ) ) {
 496+ if ( $processTitles ) {
 497+ unset( $remaining[$row->page_namespace][$row->page_title] );
 498+ } else {
 499+ unset( $remaining[$pageId] );
 500+ }
496501 }
 502+
 503+ // Store any extra fields requested by modules
 504+ $this->processDbRow( $row );
497505 }
498 -
499 - // Store any extra fields requested by modules
500 - $this->processDbRow( $row );
501506 }
502507
503508 if ( isset( $remaining ) ) {
@@ -540,21 +545,23 @@
541546
542547 $revids = self::getPositiveIntegers( $revids );
543548
544 - $tables = array( 'revision', 'page' );
545 - $fields = array( 'rev_id', 'rev_page' );
546 - $where = array( 'rev_id' => $revids, 'rev_page = page_id' );
 549+ if ( count( $revids ) ) {
 550+ $tables = array( 'revision', 'page' );
 551+ $fields = array( 'rev_id', 'rev_page' );
 552+ $where = array( 'rev_id' => $revids, 'rev_page = page_id' );
547553
548 - // Get pageIDs data from the `page` table
549 - $this->profileDBIn();
550 - $res = $db->select( $tables, $fields, $where, __METHOD__ );
551 - foreach ( $res as $row ) {
552 - $revid = intval( $row->rev_id );
553 - $pageid = intval( $row->rev_page );
554 - $this->mGoodRevIDs[$revid] = $pageid;
555 - $pageids[$pageid] = '';
556 - unset( $remaining[$revid] );
 554+ // Get pageIDs data from the `page` table
 555+ $this->profileDBIn();
 556+ $res = $db->select( $tables, $fields, $where, __METHOD__ );
 557+ foreach ( $res as $row ) {
 558+ $revid = intval( $row->rev_id );
 559+ $pageid = intval( $row->rev_page );
 560+ $this->mGoodRevIDs[$revid] = $pageid;
 561+ $pageids[$pageid] = '';
 562+ unset( $remaining[$revid] );
 563+ }
 564+ $this->profileDBOut();
557565 }
558 - $this->profileDBOut();
559566
560567 $this->mMissingRevIDs = array_keys( $remaining );
561568
Property changes on: branches/wmf/1.17wmf1/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
562569 Merged /trunk/phase3/includes/api:r89549,89574

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89549follow up r89513: avoid internal error when only invalid revids/pageids are p...gurch08:45, 6 June 2011
r89574Fix fixme on r89549reedy15:58, 6 June 2011

Status & tagging log