Page MenuHomePhabricator

Plumb revision information from ParserOptions through to ParserOutput (bypassing Parsoid)
Open, LowPublic


From @Pchelolo's comments on :

With all the speculative revision stuff, I've been thinking about 'RevisionInfo' interface. RevisionRecord would implement it, but we can have a fake one. This would at least combine all this speculative stuff into one object. It would also have more relaxed typed hints the RevisionRecord. E.g. getPage can return '?PageReference' instead of 'ProperPageIdentity'. But we can't have type covariance until we get PHP 7.4

About plumbing it up - what if we do it externally to parsoid. So, the parser function needs to get the speculativeRevId from somewhere, and right now it's ParserOptions. We already pass used parser options to ParserOutput externally to parser, with recordOption and ParserOptions::registerWatcher. We can just expand the watcher interface to have setSpeculativeRevIdUsed and call that when something is getting the setSpeculativeRevId from ParserOptions. ParserOutput can actually implement 'ParserOptionsObserver' which would have 'optionUsed' and 'setSpeculativeWhateverUsed'. When we get away from ParserOptions and do parsoid's PageConfig - PageConfig can be watchable with this same interface as well.

So this task is to plumb up the speculative revision id stuff so that it gets from the ParserOptions (or PageConfig) to the ParserOutput without Parsoid having to be aware of it (and without exposing it in the ContentMetadataCollector interface).

Event Timeline

Another option here is to use ParserOutput::setOutputFlag() (see but extended so that the flag types are string|bool not just bool. Then you wouldn't need separate flags for <Foo> and <Foo>Used --- see for example, where we ::setFlag( 'vary-revision-sha1') and then have to ::setsetRevisionUsedSha1Base36( $sha1 ) -- instead we could just ::setFlag( 'vary-revision-sha1', $sha1 ).

(See also ::setTimestamp(), ::setRevisionTimestampUsed, etc)

By using the setOutputFlag mechanism with an enumeration/constant in ParserOutputFlags we can plumb arbitrary data "through" Parsoid without having to expose it all directly to Parsoid via Parsoid's API for ContentMetadataCollector. (Note that there's also the ::setExtensionData mechanism in Parsoid which is similar, and is used to plumb data from extensions through to the ParserOutput without exposing it to core.)