Skip to content

Validate the config page with JsonValidateSave and track maps on SMW's parser - #949

Merged
JeroenDeDauw merged 2 commits into
masterfrom
fix/editfilter-hook-and-parser-getoutput
Oct 3, 2026
Merged

JeroenDeDauw merged 2 commits into
masterfrom
fix/editfilter-hook-and-parser-getoutput

Conversation

@JeroenDeDauw

@JeroenDeDauw JeroenDeDauw commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Follows-up to #948

MediaWiki 1.46 deprecates the EditFilter hook, and Maps registers it during setup, so every request logs a deprecation
warning. MediaWiki master (1.47) no longer runs it, so the MediaWiki:Maps config page accepts invalid configuration
there, contrary to the 15.0.0 release note. Validation now uses JsonValidateSave, whose interface is the same from
1.43 through master. Core runs it on every save of JSON content through PageUpdater, such as by edit.php or a
rollback, and on undeletion. Each validation error is its own fatal message and the maps-config-invalid heading is
gone, so the edit API's default error format reports the first validation error instead of hookaborted. On 1.43 to
1.46 the edit form lists the errors in one box and core escapes their parameters; master's edit form parses error
parameters as wikitext, for every extension.

With $egMapsEnableCategory enabled, the map result format read the main parser's output to decide whether to add the
tracking category. When the main parser had not parsed anything yet, as on Special:Ask or when Parsoid renders the page,
that logged a deprecation warning on 1.43 to 1.45 and was a fatal error on 1.46 and master; after an earlier parse, the
category went to that parse's output and was lost. The category is now added only for inline queries, to the parser that
SMW runs the query with, once that parser has parsed something. For #ask and #show that is the parser running the
parser function. So pages that Parsoid renders, as master's RefreshLinksJob does by default, now get the category, and
so do pages whose wikitext another extension, such as NativeMarkdown, parses on its own parser. Semantic Compound
Queries and other callers get whichever parser SMW last held, which can be idle after an earlier query; the category
then goes to that query's output and is lost.

Considered, omitted:

  • EditFilterMergedContent: core runs it only for the edit form and API, content model changes and MCR undo
  • Escaping the error parameters in Maps: on 1.43 to 1.46, where core escapes them, they would show escaped twice
  • Validating moves onto MediaWiki:Maps (MovePageIsValidMove) and imports (no hook): Maps ignores invalid values
    when it reads the page
  • SMW's parser for popup wikitext too (getParserClone()): the clone runs a parse of its own, so it does not hit this
    error; it only resolves popup links against an unrelated page
  • The tracking category for a query whose results have no coordinates: Maps still adds it before checking for
    coordinates

AI-authored — Claude Code, Opus 5.5 (max); detailed spec from @JeroenDeDauw, redesigned once on orchestrator review feedback; diff not yet human-reviewed; regression tests failed on local MediaWiki 1.43 with SMW 7 before the fixes, PHPUnit, phpcs and PHPStan pass locally, edit form, edit API, edit.php and a Parsoid render checked on 1.43, CI green including the SMW 6 and SMW 7 jobs; 1.46 and master checked against core source only.

@JeroenDeDauw
JeroenDeDauw force-pushed the fix/editfilter-hook-and-parser-getoutput branch 2 times, most recently from 62e56a6 to 81cfb2c Compare October 3, 2026 00:17
@JeroenDeDauw JeroenDeDauw changed the title Replace the EditFilter hook and add the map tracking category only during a parse Validate the config page with JsonValidateSave and track maps on SMW's parser Oct 3, 2026
@JeroenDeDauw
JeroenDeDauw force-pushed the fix/editfilter-hook-and-parser-getoutput branch from 81cfb2c to b826a8b Compare October 3, 2026 02:27
JeroenDeDauw and others added 2 commits October 3, 2026 19:31
MediaWiki 1.46 deprecates the `EditFilter` hook, and Maps registers it during setup, so every request logs a
deprecation warning. MediaWiki master (1.47) no longer runs it, so the `MediaWiki:Maps` config page accepts invalid
configuration there. `JsonValidateSave` has the same interface from 1.43 through master and runs on every save of JSON
content through `PageUpdater`, so the config is now also validated on saves without the edit form, such as with
`edit.php` or a rollback.

Each validation error goes on the save status as its own message; the `maps-config-invalid` heading message is gone.
The edit API fails with the first error instead of `hookaborted`. Core escapes the error parameters when it shows them
on 1.43 to 1.46, so escaping them here too would show them escaped twice.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
With `$egMapsEnableCategory` enabled, `MapPrinter` read the main parser's output to decide whether to add the tracking
category. When the main parser had not parsed anything yet, as on Special:Ask or when Parsoid renders the page, that
logged a deprecation warning on MediaWiki 1.43 to 1.45 and was a fatal error on 1.46 and later. After an earlier parse,
the category went to that parse's output and was lost.

The category is now added only for inline queries, to the parser that SMW runs the query with, which
`ResultPrinter::copyParser()` returns rather than a copy. For `#ask` and `#show`, SMW binds it to the parser running the
parser function, Parsoid's included, so map queries that Parsoid renders now get the category too. Other callers, such
as Semantic Compound Queries, get whichever parser SMW last held: if it has not parsed anything, the category is
skipped; if it is idle after an earlier query, the category goes to that query's output and is lost.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@JeroenDeDauw
JeroenDeDauw force-pushed the fix/editfilter-hook-and-parser-getoutput branch from b826a8b to b1a75fc Compare October 3, 2026 17:31
@JeroenDeDauw
JeroenDeDauw marked this pull request as ready for review October 3, 2026 18:42
@JeroenDeDauw
JeroenDeDauw merged commit 6167eb4 into master Oct 3, 2026
8 checks passed
@JeroenDeDauw
JeroenDeDauw deleted the fix/editfilter-hook-and-parser-getoutput branch October 3, 2026 18:42
JeroenDeDauw added a commit that referenced this pull request Oct 3, 2026
…namespace check (#950)

Follows-up to #949

`ConfigPageHooksTest` saves `MediaWiki:Maps` on the wiki's real database, so a failing run left the invalid test
config as the wiki's live configuration. A save that goes through is now undone before the assertions run.

The test for other JSON pages changed namespace and title at once, so dropping the namespace half of the config-page
check went unnoticed. It now uses a page named `Maps` in the GeoJson namespace.

`MapPrinter` imports `MapsFactory`, and its tracking-category comment no longer claims for every caller what only
holds for `#ask` and `#show`.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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