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 created this task.Nov 27 2015, 11:45 PM
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.
Restricted Application added subscribers: StudiesWorld, Aklapper. · View Herald TranscriptNov 27 2015, 11:45 PM
Yurik set Security to None.
Yurik added a subscriber: Anomie.Nov 29 2015, 12:19 AM
TheDJ added a subscriber: TheDJ.Nov 29 2015, 11:06 AM

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.

Anomie added a subscriber: aaron.Nov 29 2015, 12:36 PM

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

Yurik moved this task from Backlog to Prioritized on the Graphs board.Dec 2 2015, 11:26 PM
aaron added a comment.Dec 3 2015, 12:10 AM

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

Yurik added a comment.Jan 8 2016, 7:49 AM

@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 closed this task as Resolved.Jan 8 2016, 7:55 AM
Yurik claimed this task.

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

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