r87803 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87802‎ | r87803 | r87804 >
Date:01:04, 10 May 2011
Author:brion
Status:ok
Tags:
Comment:
Fixes for FakeResultWrapper iteration -- the rewind/next/current stuff used in RevDelete's listings wasn't quite working right here. Also returned a bogus object from fetchObject() when going beyond the end, which was not pretty!
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/Database.php
@@ -3248,7 +3248,12 @@
32493249 }
32503250
32513251 function fetchRow() {
3252 - $this->currentRow = $this->result[$this->pos++];
 3252+ if ( $this->pos < count( $this->result ) ) {
 3253+ $this->currentRow = $this->result[$this->pos];
 3254+ } else {
 3255+ $this->currentRow = false;
 3256+ }
 3257+ $this->pos++;
32533258 return $this->currentRow;
32543259 }
32553260
@@ -3260,14 +3265,22 @@
32613266
32623267 // Callers want to be able to access fields with $this->fieldName
32633268 function fetchObject() {
3264 - $this->currentRow = $this->result[$this->pos++];
3265 - return (object)$this->currentRow;
 3269+ $this->fetchRow();
 3270+ if ( $this->currentRow ) {
 3271+ return (object)$this->currentRow;
 3272+ } else {
 3273+ return false;
 3274+ }
32663275 }
32673276
32683277 function rewind() {
32693278 $this->pos = 0;
32703279 $this->currentRow = null;
32713280 }
 3281+
 3282+ function next() {
 3283+ return $this->fetchObject();
 3284+ }
32723285 }
32733286
32743287 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r87804* (bug 21279) Special:RevisionDelete now uses revision ID for deleted-page re...brion01:11, 10 May 2011

Status & tagging log