Skip to content

Fix WikibaseLocalMedia crash on MW 1.47 (OutputPage::parserOptions removed)#334

Merged
physikerwelt merged 1 commit into
MaRDI4NFDI:mainfrom
M-dev-stack:fix/wikibase-local-media-parser-options
Jul 15, 2026
Merged

Fix WikibaseLocalMedia crash on MW 1.47 (OutputPage::parserOptions removed)#334
physikerwelt merged 1 commit into
MaRDI4NFDI:mainfrom
M-dev-stack:fix/wikibase-local-media-parser-options

Conversation

@M-dev-stack

@M-dev-stack M-dev-stack commented Jul 15, 2026

Copy link
Copy Markdown

Problem

Item pages with a localMedia statement fail with an internal error on staging, e.g.
https://staging.mardi4nfdi.org/wiki/Item:Q4610:

Error: Call to undefined method MediaWiki\Output\OutputPage::parserOptions()
from extensions/WikibaseLocalMedia/src/Services/FormatterBuilder.php(30)

OutputPage::parserOptions() was deprecated in MW 1.44 and no longer exists in
wmf/1.47.0-wmf.9 (the branch this image builds, see clone_all.sh).

Note this is a second, separate incompatibility from the one reported in
MaRDI4NFDI/MaRDIRoadmap#208: that crash (ArgumentCountError in
File::getDimensionsString()) was fixed upstream in WikibaseLocalMedia 2.0.1,
which the image already gets by cloning master. This parserOptions crash
occurs earlier in the same code path and blocks the same pages.

Fix

Upstream fix exists but is not merged yet:
ProfessionalWiki/WikibaseLocalMedia#46

This PR applies the equivalent one-line change at image build time, following
the repo's existing patch convention (patch -Np1 in clone_all.sh):

  • FormatterBuilder.php: RequestContext::getMain()->getOutput()->parserOptions()
    ParserOptions::newFromContext( RequestContext::getMain() )

ParserOptions::newFromContext() is the documented replacement and exists in
both older and current MediaWiki, so the patch is version-safe. The patch is
verified to apply cleanly against current WikibaseLocalMedia master.

Also adds .gitattributes with *.patch -text so patch files are never
subject to line-ending conversion.

This is a temporary workaround — remove the patch once upstream merges
PR 46 and cuts a release.

After merge

Refs MaRDI4NFDI/MaRDIRoadmap#208

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a compatibility issue that could cause crashes when running Wikibase Local Media with MediaWiki 1.47.
    • Improved image formatting by ensuring parser options are obtained through the supported interface.

MW 1.47 removed OutputPage::parserOptions(), which WikibaseLocalMedia
still calls in FormatterBuilder, so every item page with a localMedia
statement fails with an internal error (e.g. Item:Q4610 on staging).
Upstream fix exists but is not merged yet:
ProfessionalWiki/WikibaseLocalMedia#46

Apply the equivalent one-line patch (ParserOptions::newFromContext)
at image build time, following the existing patch convention.
Remove once upstream merges PR 46 and a release is cut.

Refs MaRDI4NFDI/MaRDIRoadmap#208
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aab03f77-9631-489e-b1c0-bb6531e27dc4

📥 Commits

Reviewing files that changed from the base of the PR and between 9991dbc and 7b31145.

📒 Files selected for processing (4)
  • .gitattributes
  • Dockerfile
  • clone_all.sh
  • wikibase-local-media-parser-options.patch

📝 Walkthrough

Walkthrough

Changes

Wikibase parser options workaround

Layer / File(s) Summary
Update parser option construction
wikibase-local-media-parser-options.patch
Adds a ParserOptions import and replaces output-based parser option retrieval with ParserOptions::newFromContext.
Apply patch during image setup
Dockerfile, clone_all.sh, .gitattributes
Copies and applies the new patch during the fetcher stage and marks patch files as non-text in Git.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Dockerfile
  participant clone_all.sh
  participant WikibaseLocalMedia
  Dockerfile->>clone_all.sh: Copy parser-options patch
  clone_all.sh->>WikibaseLocalMedia: Apply patch
  WikibaseLocalMedia->>WikibaseLocalMedia: Construct ParserOptions from RequestContext
Loading

Suggested reviewers: physikerwelt

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: fixing the WikibaseLocalMedia crash on MediaWiki 1.47 caused by the removed parserOptions method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@M-dev-stack
M-dev-stack requested a review from physikerwelt July 15, 2026 11:56
@M-dev-stack

Copy link
Copy Markdown
Author

@physikerwelt eady for review - CI green, image built. Happy to also prepare the portal-k8s staging tag bump once this is merged

@physikerwelt
physikerwelt merged commit 1ae44ec into MaRDI4NFDI:main Jul 15, 2026
2 checks passed
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