We currently use the ParserAfterParse hook to inject language links, page props, etc into the ParserOutput object. This is problematic, because:
- ParserAfterParse is specific to wikitext parsing. However, injecting language links should work for any content model.
- ParserAfterParse is also called for system messages used on the edit page, inside Lua, etc. This can lead to performance issues. An attempt to only inject things when a revision ID is known to the parser (I30d12214b046) failed, presumably because of the stashedit magic pre-parsing the page before it gets saved (and this, before a revision id is present).
We should probably hook into a point further up the stack, perhaps use the ContentAlterParserOutput hook for this.