From f9cfb2a23da7d2e1534345deee0efab249cb493c Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 10 May 2011 01:04:41 +0000 Subject: [PATCH] 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! --- includes/db/Database.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 1dac87bbc4..6560abfb25 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -3248,7 +3248,12 @@ class FakeResultWrapper extends ResultWrapper { } function fetchRow() { - $this->currentRow = $this->result[$this->pos++]; + if ( $this->pos < count( $this->result ) ) { + $this->currentRow = $this->result[$this->pos]; + } else { + $this->currentRow = false; + } + $this->pos++; return $this->currentRow; } @@ -3260,14 +3265,22 @@ class FakeResultWrapper extends ResultWrapper { // Callers want to be able to access fields with $this->fieldName function fetchObject() { - $this->currentRow = $this->result[$this->pos++]; - return (object)$this->currentRow; + $this->fetchRow(); + if ( $this->currentRow ) { + return (object)$this->currentRow; + } else { + return false; + } } function rewind() { $this->pos = 0; $this->currentRow = null; } + + function next() { + return $this->fetchObject(); + } } /** -- 2.20.1