I've made some changes promoting better coding patterns in some contexts.
These are for MediaWiki 1.18, extensions can keep their old patterns till they drop support for pre-1.18. I'd like to consider dropping the rewriting of $wgTitle and $wgOut inside of SpecialPage::capturePath around MediaWiki 1.20. This means that after that release includable special pages in extensions will have to use the new patterns instead of relying on the $wg replacement hack.
When working on special pages (ESPECIALLY includable special pages): - Use $this->getOutput() instead of the $wgOut global. - Use $this->getUser() instead of the $wgUser global. - Use $this->getSkin() instead of using $wgUser->getSkin();
In contexts where you are working with $wgOut or another OutputPage instance and using $wgUser and skin instances fetched from it to render stuff being passed back to output: - Use $out->getUser() instead of the $wgUser gobal. - Use $out->getSkin() instead of using $wgUser->getSkin();
---- Extra stuff ----
I have some thought to go through on what to do about the Linker in some contexts, but I have some plans I'm thinking of regarding Skin: - I'm thinking of making $out->getSkin(); the primary point for getting a skin instead of $wgUser->getSkin(); (I'll still keep BC), making OutputPage the focal point for things related to the output of the page. Having OutputPage track and manage skins also avoids some special case bugs, it's actually more sane for OutputPage to manage the skin when you examine various branches of code. - Along with making OutputPage track the skin I'm planning on dropping support for getSkin( $t ); examining the code it's not actually even used, and the only code using it actually shouldn't be playing with a full skin at all anyways, and making Skin defer to OutputPage for most of it's title information. Instead of having 3 near-global copies of the Title floating around ($wgTitle, $wgOut->mTitle, $wgUser->getSkin()->mTitle).
I haven't decided what do about the linker yet. But I'm considering making the Parser get it's linker via $po->getLinker(); (either ParserOutput or ParserOptions, I need another look) and getting a plain linker instance instead of a skin. Skin will define a getLinker() which will replace it's subclassing of Linker (there will be some bc). To allow for the overloading of parts of the linker, which was sorta possible already, but making it more reliable, getLinker would be overridable by a skin that wanted to make linker changes so it could return a subclass of the linker. The getLinker in Parser context will take that into account, if a subclass of Linker is being used instead of the normal linker the parsercache key will change, as a result we will both make overriding linker methods reliable and usable, while also avoiding any unnecessary parser cache fragmentation which would happen if we went and included the skin name into the pcache key.
On 3 April 2011 09:17, Daniel Friesen lists@nadir-seen-fire.com wrote:
I've made some changes promoting better coding patterns in some contexts.
These are for MediaWiki 1.18, extensions can keep their old patterns till they drop support for pre-1.18.
I'd like to consider dropping the rewriting of $wgTitle and $wgOut inside of SpecialPage::capturePath around MediaWiki 1.20.
That's too fast. Needs at least few releases without and with wfDeprecated();
-Niklas
On 11-04-03 07:29 AM, Niklas Laxström wrote:
On 3 April 2011 09:17, Daniel Friesenlists@nadir-seen-fire.com wrote:
I've made some changes promoting better coding patterns in some contexts.
These are for MediaWiki 1.18, extensions can keep their old patterns till they drop support for pre-1.18. I'd like to consider dropping the rewriting of $wgTitle and $wgOut inside of SpecialPage::capturePath around MediaWiki 1.20.
That's too fast. Needs at least few releases without and with wfDeprecated();
-Niklas
How are we supposed to put wfDeprecated into all calls made to $wgOut and $wgTitle, specifically in the context of a special page?
Tbh, most extensions actually won't break when we drop support for that. The only situation where they'll break is if they are an includable special page. And that's two releases they have.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
On Sat, Apr 2, 2011 at 11:17 PM, Daniel Friesen lists@nadir-seen-fire.comwrote:
I've made some changes promoting better coding patterns in some contexts.
These are for MediaWiki 1.18, extensions can keep their old patterns till they drop support for pre-1.18.
[snip]
When working on special pages (ESPECIALLY includable special pages):
- Use $this->getOutput() instead of the $wgOut global.
- Use $this->getUser() instead of the $wgUser global.
- Use $this->getSkin() instead of using $wgUser->getSkin();
In contexts where you are working with $wgOut or another OutputPage instance and using $wgUser and skin instances fetched from it to render stuff being passed back to output:
- Use $out->getUser() instead of the $wgUser gobal.
- Use $out->getSkin() instead of using $wgUser->getSkin();
Seems like a good direction; this basically is encapsulating some of the 'global state' (which is really "web UI state") into one place, and letting us use a different set of state when appropriate.
I have some thought to go through on what to do about the Linker in some
contexts, but I have some plans I'm thinking of regarding Skin:
- I'm thinking of making $out->getSkin(); the primary point for getting
a skin instead of $wgUser->getSkin(); (I'll still keep BC), making OutputPage the focal point for things related to the output of the page. Having OutputPage track and manage skins also avoids some special case bugs, it's actually more sane for OutputPage to manage the skin when you examine various branches of code.
I'd be kind of inclined to separate out the Skin and Linker worlds a bit further; really, the HTML formatting of links and such doesn't depend on the user (except in some edge cases like stub links which could in principle be done differently). The surrounding *skin* depends on the user settings, but having to dive into a User object to get a Linker feels messy, especially if we're rendering a wiki page to go into a common cache.
IIRC the biggest remaining use case for link rendering actually being customized by skin was for the special skin used for creating static HTML dumps.
If we had another way to do that, and normalized stub linking in some way (say, by always sticking a magic class on and letting CSS deal with it) it might be cleaner to avoid having to touch a Skin object unless you're actually doing final HTML output. (This may be a bigger project though. :D)
-- brion
On 11-04-03 10:28 AM, Brion Vibber wrote:
On Sat, Apr 2, 2011 at 11:17 PM, Daniel Friesen lists@nadir-seen-fire.comwrote:
When working on special pages (ESPECIALLY includable special pages):
- Use $this->getOutput() instead of the $wgOut global.
- Use $this->getUser() instead of the $wgUser global.
- Use $this->getSkin() instead of using $wgUser->getSkin();
In contexts where you are working with $wgOut or another OutputPage instance and using $wgUser and skin instances fetched from it to render stuff being passed back to output:
- Use $out->getUser() instead of the $wgUser gobal.
- Use $out->getSkin() instead of using $wgUser->getSkin();
Seems like a good direction; this basically is encapsulating some of the 'global state' (which is really "web UI state") into one place, and letting us use a different set of state when appropriate.
I have some thought to go through on what to do about the Linker in some
contexts, but I have some plans I'm thinking of regarding Skin:
- I'm thinking of making $out->getSkin(); the primary point for getting
a skin instead of $wgUser->getSkin(); (I'll still keep BC), making OutputPage the focal point for things related to the output of the page. Having OutputPage track and manage skins also avoids some special case bugs, it's actually more sane for OutputPage to manage the skin when you examine various branches of code.
I'd be kind of inclined to separate out the Skin and Linker worlds a bit further; really, the HTML formatting of links and such doesn't depend on the user (except in some edge cases like stub links which could in principle be done differently). The surrounding *skin* depends on the user settings, but having to dive into a User object to get a Linker feels messy, especially if we're rendering a wiki page to go into a common cache.
IIRC the biggest remaining use case for link rendering actually being customized by skin was for the special skin used for creating static HTML dumps.
If we had another way to do that, and normalized stub linking in some way (say, by always sticking a magic class on and letting CSS deal with it) it might be cleaner to avoid having to touch a Skin object unless you're actually doing final HTML output. (This may be a bigger project though. :D)
-- brion
I had a short discussion and abandoned the linker as an instance idea. Now the Linker class is intended to be used entirely statically (bc for both Skins and hooks though).
I can look into static dumps sometime, I think it needed updates for one of the other skin changes as well. Why did we even pull html dumping out of core? I had some thoughts on offline/static dumping in my skin plans, and it seams to make much more sense for offline support in skins to be built in.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
Brion Vibber wrote:
I'd be kind of inclined to separate out the Skin and Linker worlds a bit further; really, the HTML formatting of links and such doesn't depend on the user (except in some edge cases like stub links which could in principle be done differently). The surrounding *skin* depends on the user settings, but having to dive into a User object to get a Linker feels messy, especially if we're rendering a wiki page to go into a common cache.
IIRC the biggest remaining use case for link rendering actually being customized by skin was for the special skin used for creating static HTML dumps.
If we had another way to do that, and normalized stub linking in some way (say, by always sticking a magic class on and letting CSS deal with it) it might be cleaner to avoid having to touch a Skin object unless you're actually doing final HTML output. (This may be a bigger project though. :D)
I filed two bugs after reading this: * Avoid parser cache fragmentation[1] * Remove stub link formatting user preference from MediaWiki core[2]
MZMcBride
[1] https://bugzilla.wikimedia.org/show_bug.cgi?id=28424 [2] https://bugzilla.wikimedia.org/show_bug.cgi?id=28426
On 11-04-04 02:40 PM, Platonides wrote:
I like it. Specially the Linker change. It really looks the way to have it.
I'm considering making the Parser get it's linker via $po->getLinker(); (either ParserOutput or ParserOptions, I need another look)
The linker would be an input parameter, so it is a ParserOptions
Yeah, I just couldn't remember which set of code that was when I wrote the e-mail...
It's moot now anyways, since Linker is now used statically as Linker::* instead.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
I second the idea of the static Linker class. It's far better than the subclass system. Skin modification of links should focus on CSS anyway, rather than trying to overload link generating code.
Daniel Friesen-4 wrote:
On 11-04-04 02:40 PM, Platonides wrote:
I like it. Specially the Linker change. It really looks the way to have it.
I'm considering making the Parser get it's linker via $po->getLinker(); (either ParserOutput or ParserOptions, I need another look)
The linker would be an input parameter, so it is a ParserOptions
Yeah, I just couldn't remember which set of code that was when I wrote the e-mail...
It's moot now anyways, since Linker is now used statically as Linker::* instead.
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org