Skip to content

Project imported pages into the graph#1066

Merged
malberts merged 1 commit into
masterfrom
fix/1022-import-graph-projection
Jul 17, 2026
Merged

Project imported pages into the graph#1066
malberts merged 1 commit into
masterfrom
fix/1022-import-graph-projection

Conversation

@JeroenDeDauw

@JeroenDeDauw JeroenDeDauw commented Jul 16, 2026

Copy link
Copy Markdown
Member

Fixes #1022

Imported revisions bypass the edit path, so RevisionFromEditComplete never fires for
them and their Subjects stayed invisible to queries until RebuildGraphDatabases.php ran.

The cause holds for only part of the import surface. Special:Import and the import API
already projected, because ImportReporter creates a null revision on top of an import
that added revisions, and fires RevisionFromEditComplete for it. importDump.php wraps
the importer in no reporter, so nothing projected there.

Handling AfterImportPage covers every path at once rather than adding a third special
case. It is fired once per page, from WikiImporter itself, once the page's revisions are
all in. A revision-insert hook was rejected because imports can add revisions to the
middle of a page's history, so it would project non-current revisions.

The handler reuses SubjectPageRebuilder, which RebuildGraphDatabases.php (the documented
workaround) already uses to project the current revision of a title. It gets the isolating
graph plugin, so a projection failure cannot abort the import, and reads the page from the
primary database, since a replica can be missing the page or still carry the revision the
import replaced. Core's own finishImportPage reads the primary for the same reason.

On Special:Import the null revision now reprojects content this hook already projected.
That is redundant rather than harmful: both writes carry the same slots and savePage
merges, so the outcome is unchanged.

Verified on a dev wiki: a page exported with dumpBackup.php and imported under a new title
via importDump.php now reaches Neo4j with its Subject, where before it had no node at all.

AI-authored — Claude Code, Opus 4.8 (max); one-line ask from @JeroenDeDauw (issue link only); no revisions; diff not yet human-reviewed; regression tests written failing-first and re-checked by mutating the fix back out, full PHPUnit suite + phpcs + phpstan green locally and on CI, plus an end-to-end importDump.php run checked against the dev wiki's Neo4j.

@JeroenDeDauw
JeroenDeDauw force-pushed the fix/1022-import-graph-projection branch from 6e53d75 to 526fb01 Compare July 16, 2026 23:06
Fixes #1022

Imported revisions bypass the edit path, so RevisionFromEditComplete never fires for
them and their Subjects stayed invisible to queries until RebuildGraphDatabases.php ran.

The cause holds for only part of the import surface. Special:Import and the import API
already projected, because ImportReporter creates a null revision on top of an import
that added revisions, and fires RevisionFromEditComplete for it. importDump.php wraps
the importer in no reporter, so nothing projected there.

Handling AfterImportPage covers every path at once rather than adding a third special
case. It is fired once per page, from WikiImporter itself, once the page's revisions are
all in. A revision-insert hook was rejected because imports can add revisions to the
middle of a page's history, so it would project non-current revisions.

The handler reuses SubjectPageRebuilder, which RebuildGraphDatabases.php (the documented
workaround) already uses to project the current revision of a title. It gets the isolating
graph plugin, so a projection failure cannot abort the import, and reads the page from the
primary database, since a replica can be missing the page or still carry the revision the
import replaced. Core's own finishImportPage reads the primary for the same reason.

On Special:Import the null revision now reprojects content this hook already projected.
That is redundant rather than harmful: both writes carry the same slots and savePage
merges, so the outcome is unchanged.

Verified on a dev wiki: a page exported with dumpBackup.php and imported under a new title
via importDump.php now reaches Neo4j with its Subject, where before it had no node at all.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JeroenDeDauw
JeroenDeDauw force-pushed the fix/1022-import-graph-projection branch from 526fb01 to 1fa3abf Compare July 16, 2026 23:25
@JeroenDeDauw
JeroenDeDauw marked this pull request as ready for review July 16, 2026 23:32
@malberts malberts assigned malberts and unassigned malberts Jul 17, 2026
@malberts
malberts merged commit cb8f364 into master Jul 17, 2026
6 checks passed
@alistair3149 alistair3149 self-assigned this Jul 17, 2026
@malberts
malberts deleted the fix/1022-import-graph-projection branch July 17, 2026 17:13
@alistair3149 alistair3149 removed their assignment Jul 17, 2026
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.

Imported revisions do not update the graph projection

3 participants