Skip to content

Fix Special:WikibaseExport constructor on MediaWiki 1.46 and later - #194

Merged
malberts merged 3 commits into
masterfrom
fix/special-page-constructor-args
Nov 12, 2026
Merged

malberts merged 3 commits into
masterfrom
fix/special-page-constructor-args

Conversation

@alistair3149

@alistair3149 alistair3149 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Special:WikibaseExport passed its read restriction to the SpecialPage constructor. MediaWiki 1.46 deprecates
that parameter and 1.47 removes it, so the page emits a deprecation warning on 1.46 and fails with "Unknown named
parameter $restriction" on 1.47. The page now declares the right by overriding getRestriction(), and still passes
it to the constructor before 1.46, where MediaWiki reads the constructor's value instead of calling
getRestriction(). Users without read stay refused before and after 1.46.

Human input

Goal and shape: goal set by @alistair3149; shape Claude's.

Outcome: not reviewed by a human yet. Left for you: the 1.46 boundary of the version check, and whether the two
tests cover the restriction you expect.

Claude's calls

  • Not discussed with @alistair3149:
    • A version-checked constructor plus a getRestriction() override, as in SimpleBatchUpload and Semantic
      MediaWiki, rather than Thumbro's overrides of isRestricted(), userCanExecute() and
      displayRestrictionError(): the check is one if to delete once 1.46 is the minimum.
    • testWrapperIsPresent becomes testShowsTheExportPageToAUserWhoMayRead, runs as a user with only read, and
      asserts only the wrapper's id, which the page's JavaScript looks up, instead of its whole opening tag. The new
      testRefusesAUserWhoMayNotRead runs as a user without read.
    • A PHPStan baseline entry for the version check, which PHPStan sees as always false on MediaWiki 1.43, as the
      baseline already does for the 1.41 check in this class.
  • Considered by Claude, omitted:
    • A release notes entry: this repo writes them in the README at release time.
    • The other MediaWiki 1.44+ incompatibilities (Use namespaced classes #190) and the 1.45 getRevisionByTitle() deprecation in
      PageContentFetcher. Until Use namespaced classes #190 is fixed, the extension still fails on 1.47 outside this constructor.
    • Adding MediaWiki 1.46 or 1.47 to the CI matrix: it would fail on Use namespaced classes #190.
  • Not verified by running: MediaWiki 1.39 to 1.42 and 1.46. For those, the behaviour rests on reading core's
    SpecialPage on each branch. Fix CI: update mediawiki-codesniffer and drop MediaWiki 1.39 to 1.42 jobs #195 fixes the Code style and Static Analysis jobs and drops the 1.39 to 1.42 jobs.
Verification evidence

Run locally on SQLite and PHP 8.3, with Wikibase from the matching REL branch.

  • MediaWiki 1.47, this branch's tests against master's SpecialWikibaseExport: both tests error with Unknown named parameter $restriction.
  • MediaWiki 1.47, this branch: testRefusesAUserWhoMayNotRead passes. testShowsTheExportPageToAUserWhoMayRead
    gets past the constructor and the permission check, then errors on the getRevisionByTitle() deprecation; with
    that deprecation filtered in a temporary, uncommitted setUp(), both tests pass. Without the getRestriction()
    override, testRefusesAUserWhoMayNotRead fails.
  • MediaWiki 1.43: with only the getRestriction() override and the name-only constructor on every version,
    testRefusesAUserWhoMayNotRead fails ("Failed asserting that exception of type "PermissionsError" is thrown");
    with this branch, it passes.
  • Full suite, MediaWiki 1.43: 118 tests OK, 3 skipped, the same skips as WikibaseExport master.
  • Full suite, MediaWiki 1.47: 14 errors on WikibaseExport master and on this branch. 13 come from the removed
    Title alias (Use namespaced classes #190); the 14th is the getRevisionByTitle() deprecation above.
  • PHPStan 1.12 on MediaWiki 1.43: no errors. PHPCS on the changed files with core's codesniffer: no findings on
    changed lines.
  • CI, on both commits: PHPUnit on MediaWiki 1.43 passes (118 tests, 3 skipped) and Linting passes. Fix CI: update mediawiki-codesniffer and drop MediaWiki 1.39 to 1.42 jobs #195 fixes the
    remaining jobs. The other six jobs fail before
    any test runs, as on master: Composer refuses to install packages that have security
    advisories (squizlabs/php_codesniffer pinned by mediawiki-codesniffer, and core's dependencies on 1.39 to 1.42).

AI-authored — Claude Code, Opus 5.5, on a Professional Wiki account

Special:WikibaseExport passed its read restriction to the SpecialPage
constructor. MediaWiki 1.46 deprecates that parameter and 1.47 removes
it, so the page emits a deprecation warning on 1.46 and fails with
"Unknown named parameter $restriction" on 1.47. The page now declares
the right by overriding getRestriction(), and still passes it to the
constructor before 1.46, where MediaWiki checks only that value. Users
without read stay refused on every supported version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test pinned the wrapper's whole opening tag, so harmless markup changes
such as attribute order failed it. The id is what the page's JavaScript
looks up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nstructor-args

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@malberts
malberts merged commit 4e38f12 into master Nov 12, 2026
8 checks passed
@malberts
malberts deleted the fix/special-page-constructor-args branch November 12, 2026 20:51
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