From: X! Date: Thu, 15 Jul 2010 22:39:48 +0000 (+0000) Subject: Move FakeResultWrapper to Database.php, allowing more special pages and extensions... X-Git-Tag: 1.31.0-rc.0~36132 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=8cc3688dfdc19dbc41846660f5233cf79837cb16;p=lhc%2Fweb%2Fwiklou.git Move FakeResultWrapper to Database.php, allowing more special pages and extensions than just Special:Allmessages to use a ResultWrapper-specific class (TablePager comes to mind) --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 251f3ba182..f75c4220b4 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -352,6 +352,7 @@ $wgAutoloadLocalClasses = array( 'DBObject' => 'includes/db/Database.php', 'DBQueryError' => 'includes/db/Database.php', 'DBUnexpectedError' => 'includes/db/Database.php', + 'FakeResultWrapper' => 'includes/db/Database.php', 'IBM_DB2Blob' => 'includes/db/DatabaseIbm_db2.php', 'LBFactory' => 'includes/db/LBFactory.php', 'LBFactory_Multi' => 'includes/db/LBFactory_Multi.php', @@ -536,7 +537,6 @@ $wgAutoloadLocalClasses = array( 'EmailConfirmation' => 'includes/specials/SpecialConfirmemail.php', 'EmailInvalidation' => 'includes/specials/SpecialConfirmemail.php', 'SpecialEmailUser' => 'includes/specials/SpecialEmailuser.php', - 'FakeResultWrapper' => 'includes/specials/SpecialAllmessages.php', 'FewestrevisionsPage' => 'includes/specials/SpecialFewestrevisions.php', 'FileDuplicateSearchPage' => 'includes/specials/SpecialFileDuplicateSearch.php', 'IPBlockForm' => 'includes/specials/SpecialBlockip.php', @@ -603,7 +603,6 @@ $wgAutoloadLocalClasses = array( 'SpecialTags' => 'includes/specials/SpecialTags.php', 'SpecialUnlockdb' => 'includes/specials/SpecialUnlockdb.php', 'SpecialUpload' => 'includes/specials/SpecialUpload.php', - 'SpecialUserlogout' => 'includes/specials/SpecialUserlogout.php', 'SpecialVersion' => 'includes/specials/SpecialVersion.php', 'SpecialWhatlinkshere' => 'includes/specials/SpecialWhatlinkshere.php', 'SpecialWhatLinksHere' => 'includes/specials/SpecialWhatlinkshere.php', diff --git a/includes/db/Database.php b/includes/db/Database.php index e4f278e355..fef3e32bc1 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -2835,6 +2835,47 @@ class ResultWrapper implements Iterator { } } +/* Overloads the relevant methods of the real ResultsWrapper so it + * doesn't go anywhere near an actual database. + */ +class FakeResultWrapper extends ResultWrapper { + + var $result = array(); + var $db = null; // And it's going to stay that way :D + var $pos = 0; + var $currentRow = null; + + function __construct( $array ){ + $this->result = $array; + } + + function numRows() { + return count( $this->result ); + } + + function fetchRow() { + $this->currentRow = $this->result[$this->pos++]; + return $this->currentRow; + } + + function seek( $row ) { + $this->pos = $row; + } + + function free() {} + + // Callers want to be able to access fields with $this->fieldName + function fetchObject(){ + $this->currentRow = $this->result[$this->pos++]; + return (object)$this->currentRow; + } + + function rewind() { + $this->pos = 0; + $this->currentRow = null; + } +} + /** * Used by DatabaseBase::buildLike() to represent characters that have special meaning in SQL LIKE clauses * and thus need no escaping. Don't instantiate it manually, use Database::anyChar() and anyString() instead. diff --git a/includes/specials/SpecialAllmessages.php b/includes/specials/SpecialAllmessages.php index 902e6c5395..ec6a09e4ac 100644 --- a/includes/specials/SpecialAllmessages.php +++ b/includes/specials/SpecialAllmessages.php @@ -393,43 +393,4 @@ class AllmessagesTablePager extends TablePager { return ''; } } -/* Overloads the relevant methods of the real ResultsWrapper so it - * doesn't go anywhere near an actual database. - */ -class FakeResultWrapper extends ResultWrapper { - - var $result = array(); - var $db = null; // And it's going to stay that way :D - var $pos = 0; - var $currentRow = null; - - function __construct( $array ){ - $this->result = $array; - } - - function numRows() { - return count( $this->result ); - } - - function fetchRow() { - $this->currentRow = $this->result[$this->pos++]; - return $this->currentRow; - } - function seek( $row ) { - $this->pos = $row; - } - - function free() {} - - // Callers want to be able to access fields with $this->fieldName - function fetchObject(){ - $this->currentRow = $this->result[$this->pos++]; - return (object)$this->currentRow; - } - - function rewind() { - $this->pos = 0; - $this->currentRow = null; - } -}