daniel added a comment.

Investigating this took me deep into the wonderful land of ParserOptions, 
ParserOutput, ParserCache and OutputPage.

So the issue is that the parser cache should be split on whether "editsection" 
links are present in the output. But MediaWiki doesn't do that. So here is what 
I found.

- MediaWiki core actually has provisions for it: ParserOptions::optionsHash 
considers a flag called "editsection".
- But that flag is only considered if it was registered via 
ParserOutput::registerOption. This is where it gets arcane...
- Parser::clearState registers ParserOutput::registerOption as a "watcher" with 
ParserOptions
- ParserOptions calls back to the watcher whenever a "relevant" option is read, 
e.g. getUserLang() is called.

So, Parser::clearState enables the automatic splitting of the cache by 
registering the ParserOutput was a watcher to the ParserOptions. But Wikibase 
doesn't use the parser, and EntityParserOutputGerator doesn't register the 
watcher. So no automated splitting.

Now the splitting by user language is automatic (we do that somewhere 
explicitly - that's no longer needed then, I suppose). But it //still// doesn't 
work for editsection.

As it turns out, ParserOptions::getEditSection does not call $this->optionUsed( 
'editsection' ), as I expected, following the example of getUserLang(), 
getThumbSize(), etc.  The reason it doesn't is apparently another magic trick:

- Parser emits special <mw:editsection> tags and registers a replacement token 
in the ParserOutput
- These get replaced by the actual HTML for the editsection by 
ParserOutput::getText, using thetokens it got via 
ParserOutput::setEditSectionTokens.
- ParserOutput::getText delegates the generation of the actual section link to 
Skin::doEditSectionLink

We could try to use that mechanism by putting an <mw:editsection> tag into the 
wikibase-toolbar-bracketed template, and then customizing the output via the 
DoEditSectionLink hook called by Skin::doEditSectionLink.

But the simples solution would be to just call $parserOutput->recordOption( 
'editsection' ) in EntityParserOutputGenerator. We don't even need to set up 
the "split cache automatically via watcher" magic for that to work, though I 
think we should do that anyway.


TASK DETAIL
  https://phabricator.wikimedia.org/T85252

REPLY HANDLER ACTIONS
  Reply to comment or attach files, or !close, !claim, !unsubscribe or !assign 
<username>.

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: aude, daniel
Cc: Tobi_WMDE_SW, aude, Aklapper, Lydia_Pintscher, daniel, JohnLewis, hoo, 
Wikidata-bugs, Jdouglas



_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to