Page MenuHomePhabricator

Provide a way to easily affect content rendering
Open, NormalPublic

Description

Currently it is not easily to affect content rending with hooks, because the hooks that are available also modify the content in a way that shows up in diffs, pre-fillings of MediaWiki namespace pages and what else.


Version: 1.18.x
Severity: normal

Details

Reference
bz28302

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 21 2014, 11:24 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz28302.
bzimport added a subscriber: Unknown Object (MLST).

This issue blocks the resolved bug 28301. Does this mean this issue should be closed/wfm now because it was resolved without us paying attention?

olivier.beaton wrote:

Could this be considered equivalent to the question of how to properly hook article content pre-parse wikitext?

http://www.mediawiki.org/wiki/Manual_talk:Hooks/ParserBeforeStrip#Detect_Parse_of_Article_Content_.2F_Hack_removal

If so, adding metadata, perhaps to $parser->getOptions() that let you know what the item you were parsing was, (not the title of the page the item is found on) would go a long way to making ParseBeforeStrip more useful.

There are multiple problems with this, some of which I gave in the description.

olivier.beaton wrote:

The ArticleAfterFetchContent is not bad,
http://www.mediawiki.org/wiki/Manual:Hooks/ArticleAfterFetchContent
it gives you a $article and $content before wikitext is parsed. You can use $article->getContext()->getRequest->getVal('action', 'view') to then determine how the content will be used.

I've havent checked every type (diffs for examples) but you may be able to differentiate between those and a standard viewing.

No I don't want to change the content, I want to change the display of the content, and only normal page views.

olivier.beaton wrote:

That's what I'm talking about. If you hook ArticleAfterFetchContent and check that 'action' === ('view' || 'purge' || 'print') you only change the display. True you have to change the cached display (you can invalidate the cache), but you can't win at everything.

Of course a better hook that gets called every time would be nice (but provide a bigger performance impact). Or a hook where we don't have to constantly tweak for the types of display/export MW is doing.

That's exactly the point, I don't want to do any action === foobarbaz checks and update the list all the time. I also don't want affect the content, because if user edits it will mess up saves.

I wonder if this is now easily possible with ContentHandler?