Page MenuHomePhabricator

Pull OutputPage::setSections($parserOutput->getSections()) into OutputPage::addParserOutputMetadata()
Closed, ResolvedPublic

Description

These method calls often occur together, ie from EditPage.php:

$out->setSections( $parserOutput->getSections() );
$out->addParserOutputMetadata( $parserOutput );

These can probably be combined, pulling the setSections call into addParserOutputMetadata.

See https://codesearch.wmcloud.org/deployed/?q=addParserOutputMetadata&i=nope&files=&excludeFiles=&repos=

Follow up to T317333#8223090

Event Timeline

matmarex subscribed.

The other one is that addParserOutputMetadata doesn't set the section data. So practically every call to OutputPage::addParserOutput() is preceded by a call to OutputPage::setSections( $parserOutput->getSections()). It seems like we should really fold that into addParserOutput... but I suspect there are probably cases where we *don't* want to overwrite the section data, so I'm going to split that refactor into a separate task.

I've reviewed the calls to addParserOutput...() in core, haven't found any where this change would be incorrect, and I found one where it actually fixes a bug (now filed as T325600).

Change 869326 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] OutputPage: Call setSections() from addParserOutputMetadata()

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

Change 869328 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/FlaggedRevs@master] Remove redundant calls to OutputPage::setSections()

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

Change 869326 merged by jenkins-bot:

[mediawiki/core@master] OutputPage: Call setSections() from addParserOutputMetadata()

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

Change 869328 merged by jenkins-bot:

[mediawiki/extensions/FlaggedRevs@master] Remove redundant calls to OutputPage::setSections()

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

Thanks so much for tackling this!