r89549 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89548‎ | r89549 | r89550 >
Date:08:45, 6 June 2011
Author:gurch
Status:resolved (Comments)
Tags:
Comment:
follow up r89513: avoid internal error when only invalid revids/pageids are passed
Modified paths:
  • /trunk/phase3/includes/api/ApiPageSet.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiPageSet.php
@@ -451,17 +451,19 @@
452452
453453 $pageids = self::getPositiveIntegers( $pageids );
454454
455 - $set = array(
456 - 'page_id' => $pageids
457 - );
458 - $db = $this->getDB();
 455+ if ( count( $pageids ) ) {
 456+ $set = array(
 457+ 'page_id' => $pageids
 458+ );
 459+ $db = $this->getDB();
459460
460 - // Get pageIDs data from the `page` table
461 - $this->profileDBIn();
462 - $res = $db->select( 'page', $this->getPageTableFields(), $set,
463 - __METHOD__ );
464 - $this->profileDBOut();
465 -
 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+
466468 $this->initFromQueryResult( $res, $remaining, false ); // process PageIDs
467469
468470 // Resolve any found redirects
@@ -540,21 +542,23 @@
541543
542544 $revids = self::getPositiveIntegers( $revids );
543545
544 - $tables = array( 'revision', 'page' );
545 - $fields = array( 'rev_id', 'rev_page' );
546 - $where = array( 'rev_id' => $revids, 'rev_page = page_id' );
 546+ if ( count( $revids ) ) {
 547+ $tables = array( 'revision', 'page' );
 548+ $fields = array( 'rev_id', 'rev_page' );
 549+ $where = array( 'rev_id' => $revids, 'rev_page = page_id' );
547550
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] );
 551+ // Get pageIDs data from the `page` table
 552+ $this->profileDBIn();
 553+ $res = $db->select( $tables, $fields, $where, __METHOD__ );
 554+ foreach ( $res as $row ) {
 555+ $revid = intval( $row->rev_id );
 556+ $pageid = intval( $row->rev_page );
 557+ $this->mGoodRevIDs[$revid] = $pageid;
 558+ $pageids[$pageid] = '';
 559+ unset( $remaining[$revid] );
 560+ }
 561+ $this->profileDBOut();
557562 }
558 - $this->profileDBOut();
559563
560564 $this->mMissingRevIDs = array_keys( $remaining );
561565

Sign-offs

UserFlagDate
Reedyinspected09:52, 6 June 2011 (struck 09:52, 6 June 2011)
Reedytested09:52, 6 June 2011 (struck 09:52, 6 June 2011)

Follow-up revisions

RevisionCommit summaryAuthorDate
r89574Fix fixme on r89549reedy15:58, 6 June 2011
r89646MFT r89549, r89574reedy14:04, 7 June 2011
r92339REL1_18 MFT r89401, r89451, r89512, r89513, r89523, r89529, r89532, r89549, r...reedy23:08, 15 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89513Followup r89512...reedy18:01, 5 June 2011

Comments

#Comment by Reedy (talk | contribs)   09:53, 6 June 2011

api.php?action=query&pageids=-1|-2

Notice: Undefined variable: res in /home/reedy/mediawiki/trunk/phase3/includes/api/ApiPageSet.php on line 467

Warning: Invalid argument supplied for foreach() in /home/reedy/mediawiki/trunk/phase3/includes/api/ApiPageSet.php on line 488

Status & tagging log