Skip to content

Handle OutputPage parser options API differences in FormatterBuilder#1

Draft
physikerwelt with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-issue-208-comment-4956932774
Draft

Handle OutputPage parser options API differences in FormatterBuilder#1
physikerwelt with Copilot wants to merge 1 commit into
masterfrom
copilot/fix-issue-208-comment-4956932774

Conversation

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown

Rendering local media values regressed on newer/variant MediaWiki deployments because FormatterBuilder called OutputPage::parserOptions() unconditionally, which is not available in all target versions. This caused entity page rendering to fail before formatting could proceed.

  • Compatibility fix in parser options resolution

    • Replaced the direct RequestContext::getMain()->getOutput()->parserOptions() call with version-tolerant resolution logic.
    • FormatterBuilder now:
      1. uses OutputPage::parserOptions() when present,
      2. falls back to OutputPage::getParserOptions() when present,
      3. falls back to ParserOptions::newFromAnon() as a safe default.
  • Scope and behavior

    • Change is isolated to src/Services/FormatterBuilder.php.
    • No functional change to formatter selection logic; only parser-options acquisition path was made resilient.
private function getParserOptions( OutputPage $outputPage ): ParserOptions {
	if ( method_exists( $outputPage, 'parserOptions' ) ) {
		return $outputPage->parserOptions();
	}

	if ( method_exists( $outputPage, 'getParserOptions' ) ) {
		return $outputPage->getParserOptions();
	}

	return ParserOptions::newFromAnon();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants