Page MenuHomePhabricator

Internal article fetching not possible when viewing old versions
Closed, InvalidPublic

Description

Author: tderouin

Description:
We have a customization such that we can categorize articles from a drop down
list, we do something like this:

$t = Title::newFromDBKey("WikiHowCategories");
$a = new Article($t);
$cat_array = split("\n", $a->getContent(true, true));

The problem is is that article::LoadContent references "oldid" parameter in the
request, so even if you specify an article of "title x" getContent will always
return the content of the current old version of the article you're viewing.

While this works for Wikipedia, if anyone wants to build on top of the software,
it can be a very limiting feature. Possible solutions are adding default
parameters to getContent which ignore the values in wgRequest for oldid and
redirect. It should be possible to load the content of an arbitrary article from
the code when viewing an old version of a particular page.


Version: 1.4.x
Severity: normal
OS: Windows XP
Platform: PC

Details

Reference
bz3375

Event Timeline

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

As of 1.5 you should use the Revision class for this:

$rev = Revision::newFromTitle( $t );
if( is_null( $rev ) ) {

// no such page

} else {

$text = $rev->getText();
// fetched current revision text...

}

If you need to run on 1.4 you might try
Article::getContentWithoutUsingSoManyDamnGlobals().

tderouin wrote:

Good to know. Thanks.
Feel free to mark as Invalid then.