Manual:Hooks/ImportHandleRevisionXMLTag

From Linux Web Expert

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

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:ImportHandleRevisionXMLTag extensions</tvar>.</translate>


Details

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().