Jump to content

Manual:Hooks/ImportHandleRevisionXMLTag

From mediawiki.org
ImportHandleRevisionXMLTag
Available from version 1.17.0
When parsing a XML tag in a page revision.
Define function:
public static function onImportHandleRevisionXMLTag( $importer, $pageInfo, $revisionInfo ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ImportHandleRevisionXMLTag": "MediaWiki\\Extension\\MyExtension\\Hooks::onImportHandleRevisionXMLTag"
	}
}
Called from: File(s): import/WikiImporter.php
Interface: ImportHandleRevisionXMLTagHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:ImportHandleRevisionXMLTag extensions.


Details

[edit]

This hook is called every time an XML tag inside a <revision> is encountered during the import process. The hook can do something with that XML and return false to prevent the importer from processing it or return true to let the importer handle.

So for example, for this XML chunk:

<revision>
 <rev_id>1</rev_id>
 <color>Blue</color>
</revision>

this hook would be called once for 'rev_id' and once for 'color'.

  • $importer: The WikiImporter object
  • $pageInfo: An array of xml tag names => xml tag content for the <page> object
  • $revisionInfo: An array of xml tag names => xml tag contents for the <revision> object

Notes:

The two array parameters only contain the tags encountered up to this point by the importer. They will later be used to construct the revision and page objects to be inserted into the database. The name and the contents of the tag currently being processed can be accessed with $importer->getReader().