Page MenuHomePhabricator

Article::getOldIDFromRequest fails to consider mTitle vs wgTitle
Closed, InvalidPublic

Description

Author: tderouin

Description:
This function pulls out oldid from the wgRequest but fails to consider whether
or not the currrent article is actually the article being referenced in the
request, so in the case where article->mTitle is different than $wgTitle, this
always loads the article specified by oldid. This doesn't really affect
wikipedia, but in other sites that have modifications that load articles
internally, any functionality that does a article->getContent() will be broken
if there's an oldid in the URL. I think a simple solution would be just to check
if the current article's title is actually the global title:

global $wgRequest, $wgTitle;

$this->mRedirectUrl = false;

if (! ($wgTitle->getNamespace() == $this->mTitle->getNamespace() &&
       $wgTitle->getText() == $this->mTitle->getText() ) )
    return 0;

Version: 1.7.x
Severity: minor
OS: Mac OS X 10.0
Platform: Macintosh

Details

Reference
bz6822

Event Timeline

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

If you specify an oldid, it's supposed to load that page. This
allows permalinks to be made.

Not a bug.

tderouin wrote:

Right, if you are only loading the article that has been requested.

But if your code loads ANOTHER article internally (say to populate a drop down
menu), if there's an oldid in the URL, it gets the article that's requested in
the URL, which isn't good. Like I said, this is fine for Wikipedia, but if
anyone is extending the functionality of Mediawiki, it's really problematic.

No, that's how MediaWiki is meant to work. If your extension
relies on $_REQUEST['title'] it is incorrect and will fail.

tderouin wrote:

I'm not sure what you mean.

My extension doesn't rely on what's in $_REQUEST['title']. We have feature that
allows users to categorize articles through a drop down menu, these categories
are defined by the contents of an article, Project:Categories. This allows
admins to maintain the categories without coding changes.

To populate the drop down menu, we fetch Article->getContent(). When editing an
out of date article, say for an article titled "Fry Fish", and populating the
drop down:

$t = Title::newFromDBKey("Category");
$a = new Article($t);
$cats = $a->getContent();

returns the content of "Fry Fish" version from the oldid 19203, despite
a->mTitle being for the title "Category".