Bah, that looks even uglier. If you're going to make a singleton, make it something sane and reasonable.
User::getCurrent();
It's would be part of the class actually being mentioned, and it specifies what you are trying to get, the user of the current transaction. Same would go for other things like Title::getCurrent();
However, unfortunately part of things done at times are testing $wgTitle if it's null (has been set yet), and sometimes there are reasons to override it (Special use, primarily things outside of the scope of a article view). In those cases we should also probably setup things like TITLE_ISINSTANTIATED and also allow a Title::setCurrent();
Unfortunately, the parser isn't that easy. You'd think Parser::singleton() would be ok, but it's not. We'd need to be passing around a $wgParserconf and use the 'class' to determine what to get, but even that wouldn't work right.
~Daniel Friesen(Dantman) of: -The Gaiapedia (http://gaia.wikia.com) -Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG) -and Wiki-Tools.com (http://wiki-tools.com)
Bryan Tong Minh wrote:
On Thu, May 22, 2008 at 12:05 PM, Tim Starling tstarling@wikimedia.org wrote:
== Global variables are evil ==
[...]
If you do need to use a legacy global variable such as $wgUser, just put the global statement where it's needed. Don't pull the object out of the global namespace and pass it from function to function unless there's a concrete need for that versatility.
Time to deprecate all of them in favor of something like MediaWiki::singleton()->getUser(); ? It's probably slower but less evil.
Bryan
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l