[Mediawiki-l] wrong function use?

Brion Vibber brion at wikimedia.org
Thu Aug 30 13:27:26 UTC 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Johannes Perl wrote:
> I've some sort of problem with the glossary extension.
> The following lines should read the glossary page and they simply do in a
> normal case.
> 
> $title = Title::makeTitle( null , 'Glossary' );
> $emoticonListArticle = new Article( $title );
> $content = $emoticonListArticle->getContent();
> 
> But if an oldid is set (permanent link on article), they aren't reading the
> glossary, but the text of the actual article.
> Is this a normal behaviour of mediawiki? Can anyone tell my why this
> happens?

Because Article::getContent() is horrible and should never be used by
anybody outside of internal code that does article views. :)

For clean behavior, use the Revision class:

$rev = Revision::newFromTitle( $rev );
if( $rev ) {
    $content = $rev->getText();
} else {
    // Maybe do a nice error message here?
    $content = '';
}

- -- brion vibber (brion @ wikimedia.org)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG1sW+wRnhpk1wk44RAtzsAKDGN9ujdokX6IhnzCMwvjjLvUaG6QCfTOL1
2+/cPh8KYYTPpfNaIV8LsZk=
=vibH
-----END PGP SIGNATURE-----



More information about the MediaWiki-l mailing list