Skip to content

Fix _PAGEIMG annotation on MediaWiki 1.46 (PageImages::getPageImage() removed) - #287

Merged
alistair3149 merged 1 commit into
masterfrom
fix-pageimages-mw146
Aug 31, 2026
Merged

Fix _PAGEIMG annotation on MediaWiki 1.46 (PageImages::getPageImage() removed)#287
alistair3149 merged 1 commit into
masterfrom
fix-pageimages-mw146

Conversation

@alistair3149

Copy link
Copy Markdown
Member

Summary

On MediaWiki 1.46, _PAGEIMG annotation throws an uncaught Error. Because the throw happens before any property value is written, it aborts the whole smw.update job — so all semantic data for the page is lost, not just the page-image annotation.

Error: Call to undefined method PageImages\PageImages::getPageImage()
  in .../SemanticExtraSpecialProperties/src/PropertyAnnotators/PageImagesPropertyAnnotator.php on line 80

Root cause

PageImages\PageImages::getPageImage() was deprecated in MW 1.45 and removed in MW 1.46.

PageImages.PageImages service static getPageImage() instance getImage()
REL1_43 ✗ (no ServiceWiring.php)
REL1_44
REL1_45 (deprecated)
REL1_46 removed

The existing class_exists( '\PageImages\PageImages' ) guard cannot catch this — the class still exists, only the static method is gone.

Impact

getPageImage() is called from getPageImageTitle(), called from addAnnotation() before addPropertyObjectValue() runs. There is no try/catch in the class, so the Error propagates out of the annotator and kills the entire job.

Observed on a production wiki (MW 1.46, SMW 7.1.0-alpha, PHP 8.4): every job in every sampled runner invocation failed, with the queue entering "reached": "none-ready" and a backoff set on smw.update.

{
  "jobs": [
    { "type": "smw.update", "status": "failed",
      "error": "Error: Call to undefined method PageImages\\PageImages::getPageImage() in …/PageImagesPropertyAnnotator.php on line 80",
      "time": 3700 }
  ],
  "reached": "none-ready"
}

The fix

Prefer the PageImages.PageImages service (registered since MW 1.44) and its instance method getImage( Title ): ?File, falling back to the static method so MW 1.43 — the oldest version extension.json supports ("MediaWiki": ">= 1.43") — keeps working.

This matches the migration path named in PageImages' own commit introducing the service: $services->getService( 'PageImages.PageImages' )->getImage( $title ).

ServiceContainer::hasService() is available across the whole supported range — MW 1.43 and 1.46 both pin wikimedia/services 4.0.0, which has it. getImage() returns ?File, so ?? false preserves the declared File|bool return type.

Behaviour is otherwise unchanged: if PageImages is not installed, class_exists() is false and the method returns false exactly as before.

Why CI did not catch it

.github/workflows/ci.yaml covers MW 1.43, 1.44 and 1.45 only. MW 1.46 — the sole version where the method is absent — is untested, while extension.json declares ">= 1.43" with no upper bound. Adding 1.46 to the matrix would be worthwhile as a follow-up.

Testing

  • php -l clean.
  • Verified by source inspection against PageImages REL1_43/REL1_44/REL1_45/REL1_46 and wikimedia/services 4.0.0.
  • Not yet exercised against a live 1.46 install — I'd appreciate a second pair of eyes on whether PageImages.PageImages is reliably available at the point the annotator runs inside a job.

PageImages\PageImages::getPageImage() was deprecated in MediaWiki 1.45 and
removed in MediaWiki 1.46, so PageImagesPropertyAnnotator throws

  Error: Call to undefined method PageImages\PageImages::getPageImage()

on 1.46. The existing class_exists() guard cannot catch this: the class still
exists, only the static method is gone.

The throw happens in getPageImage() -> getPageImageTitle() -> addAnnotation(),
before any addPropertyObjectValue() call completes. Since nothing in the class
catches it, the Error propagates out of the annotator and aborts the entire
smw.update job, so *all* semantic data for the page is lost -- not just the
page image annotation.

Prefer the PageImages.PageImages service (registered since MW 1.44) and its
instance method getImage( Title ): ?File, falling back to the static method so
MW 1.43 -- the oldest version extension.json supports -- keeps working.
ServiceContainer::hasService() is available across the whole supported range;
MW 1.43 and 1.46 both pin wikimedia/services 4.0.0.

getImage() returns ?File, so `?? false` preserves the declared File|bool
return type of getPageImage().

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014voSKNULm15JZokJ4CqBJk
@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.71%. Comparing base (c37f4e9) to head (cbcb041).

Files with missing lines Patch % Lines
...PropertyAnnotators/PageImagesPropertyAnnotator.php 0.00% 6 Missing ⚠️

❌ Your project check has failed because the head coverage (87.71%) is below the adjusted base coverage (88.23%). You can increase the head coverage or adjust the Removed Code Behavior.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #287      +/-   ##
============================================
- Coverage     88.14%   87.71%   -0.43%     
- Complexity      377      379       +2     
============================================
  Files            40       40              
  Lines          1021     1026       +5     
============================================
  Hits            900      900              
- Misses          121      126       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alistair3149
alistair3149 merged commit 39383ad into master Aug 31, 2026
6 checks passed
@alistair3149
alistair3149 deleted the fix-pageimages-mw146 branch August 31, 2026 20:43
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.

1 participant