Background
The "main" ParserOutput object of a pageview is not exposed to skins or extensions via OutputPage. I believe this is because there can be more than one. Instead, this metadata is internally accumulated/collected via OutputPage::addParserOutputMetadata, and then exposed either via OutputPage itself (e.g. indicators, categories, modules, jsconfigvars) or via OutputPage::getMetadata (language links, template links, image links).
This avoids incurring database queries to link tables in skins or extensions to retreive this (and, consequently, avoids the problem of the page and the data disagreeing, e.g. due to oldid pageviews, poolcounter stale fallback, database replag, or when when page content varies by a user preference or query parameter, such as uselang or useparsoid).
Impact
"Page properties" are stored through the LinkTable component and retreived from the ParserCache in the ParserOutput object, but the mostly unused and not exposed in OutputPage.
This leads to extension developers adding database queries to retreive page properties for the current page, such as (Codesearch):
- DiscussionTools example (onBeforePageDisplay > isFeatureEnabledForOutput > .. > PageProps::get)
- PageImages example (onBeforePageDisplay > .. > select page_props)
- MultimediaViewer example (T439182)
Besides those three current issues, the following are past issues that have worked around this in various ways, usually by deploying a magic monkey that manually carries the page property from ParserOutput to OutputPage via a onOutputPageParserOutput hook (Codesearch)
- Wikibase: wikibase_item
- Disambiguator: disambiguation
- GeoCrumbs: geocrumb-is-in (kind of)
- PageTriage: noindex (kind of)
- Wikisource: disambiguation (kind of)
Goal
Extensions developers should be able to write this ...
public function onBeforePageDisplay( $outputPage ): void { $isDisambig = $outputPage->getProperty( 'disambiguation' ) !== null; }
... instead of this:
public function onOutputPageParserOutput( $outputPage, $parserOutput ): void { $isDisambig = $parserOutput->getPageProperty( 'disambiguation' ); if ( $isDisambig !== null ) { $outputPage->setProperty( 'disambiguation', $isDisambig ); } } public function onBeforePageDisplay( $outputPage ): void { $isDisambig = $outputPage->getProperty( 'disambiguation' ) !== null; }
public function onBeforePageDisplay( $outputPage ): void { $isDisambig = MediaWikiServices::getInstance() ->getPageProps() ->getProperties( $outputPage->getTitle() ); }