Page MenuHomePhabricator

Force re-parsing on save even if it was parsed for preview
Closed, ResolvedPublic

Description

During the preview, the custom parser tag <graph> needs to generate different HTML than during the save. It seems that the $parser->getOptions()->getIsPreview() is almost meaningless, as parser reuses previous parsing result even if it was done in preview mode. Is there an option to indicate that preview parsing is not valid for the final result?

Event Timeline

Yurik raised the priority of this task from to Needs Triage.
Yurik updated the task description. (Show Details)
Yurik added a project: MediaWiki-Parser.
Yurik added subscribers: Yurik, ori.

Hmm, not entirely sure how this works, but with ParserOutput's recordOption, you should be able to introduce additional cache variance. includes/content/MessageContent.php does this for instance.

@TheDJ, so I should add $po->recordOption( 'preview' ); in case preview is true? The recordOption() was added by @hashar.

You really should talk about this with @aaron or @ori, bypassing the reuse is going to impact save performance.

ParserOutput->mAccessedOptions has been added by https://www.mediawiki.org/wiki/Special:Code/MediaWiki/70783

I haven't played with the Parser in ages but varying output based on preview would do it, though you would only want to vary when the graph tag got used.

The vary-revision flag would probably also force the behaviour you want, although using it for this case is kind of hacky.

The parser should probably keep track of if isPreview is called, and if it is not reuse that particular paserOutput if is.

r

What is the difference between the preview and save output? Can fragmentation be avoided by post-processing?

Change 263039 had a related patch set uploaded (by Yurik):
Fixed preview caching polluting parser cache

https://gerrit.wikimedia.org/r/263039

@aaron, preview is different because it has to bring the graph's spec to the client from the start (interactive), because it is not stored anywhere, and graphoid service will not be able to render it. I'm working on it as part of T119043.

Yurik claimed this task.

Change 263039 merged by jenkins-bot:
Fixed preview caching polluting parser cache

https://gerrit.wikimedia.org/r/263039