Page MenuHomePhabricator

ResultWrapper inconsistency regarding rows
Closed, InvalidPublic

Description

Author: mediawiki-bugzilla

Description:
Hi, if I do the following I am receiving lots of results:

$t = Title::newFromText("Main_Page");
$dbr = wfGetDB(DB_SLAVE);
while ($row = $dbr->fetchObject(Revision::fetchRevision($t))) {

var_dump($row);

}

However, doing the following I am only receving a single result:

$t = Title::newFromText("Main_Page");
$r = Revision::fetchRevision($t);
$dbr = wfGetDB(DB_SLAVE);
while ($row = $dbr->fetchObject($r)) {

var_dump($row);

}

The same here:

$dbr = wfGetDB(DB_SLAVE);
$t = Title::newFromText("Main_Page");
$r = ResultWrapper ($dbr, Revision::fetchRevision($t));
while ($row = $dbr->fetchObject($r)) {

var_dump($row);

}

And to top it, if I change the code at top to the following, I receive the output "1", too:

$t = Title::newFromText("Main_Page");
print Revision::fetchRevision($t)->numRows();

Can somebody explain why it is this inconsistent? Is there something I'm doing wrong?


Version: 1.11.x
Severity: normal

Details

Reference
bz11706

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:56 PM
bzimport set Reference to bz11706.
bzimport added a subscriber: Unknown Object (MLST).

mediawiki-bugzilla wrote:

Third example should read

$r = new ResultWrapper ($dbr, Revision::fetchRevision($t));

of course.

mediawiki-bugzilla wrote:

Scrap that, as brion pointed out the first example does a new query for the revisions on every loop, that's why it never finishes... :P