MediaWiki master
WikiImporter Class Reference

XML file reader for the page data importer. More...

Public Member Functions

 __construct (ImportSource $source, Authority $performer, Config $config, HookContainer $hookContainer, Language $contentLanguage, NamespaceInfo $namespaceInfo, TitleFactory $titleFactory, WikiPageFactory $wikiPageFactory, UploadRevisionImporter $uploadRevisionImporter, IContentHandlerFactory $contentHandlerFactory, SlotRoleRegistry $slotRoleRegistry)
 Creates an ImportXMLReader drawing from the source provided.
 
 beforeImportPage ( $titleAndForeignTitle)
 Default per-page callback.
 
 debug ( $data)
 
 disableStatisticsUpdate ()
 Statistics update can cause a lot of time.
 
 doImport ()
 Primary entry point.
 
 finishImportPage (PageIdentity $pageIdentity, $foreignTitle, $revCount, $sRevCount, $pageInfo)
 Mostly for hook use.
 
 getReader ()
 
 importLogItem ( $revision)
 Default per-revision callback, performs the import.
 
 importRevision ( $revision)
 Default per-revision callback, performs the import.
 
 importUpload ( $revision)
 Dummy for now...
 
 nodeAttribute ( $attr)
 Retrieves the contents of the named attribute of the current element.
 
 nodeContents ()
 Shouldn't something like this be built-in to XMLReader? Fetches text contents of the current element, assuming no sub-elements or such scary things.
 
 notice ( $msg,... $params)
 
 pageCallback ( $title)
 Notify the callback function when a new "<page>" is reached.
 
 setDebug ( $debug)
 Set debug mode...
 
 setImageBasePath ( $dir)
 
 setImportTitleFactory ( $factory)
 Sets the factory object to use to convert ForeignTitle objects into local Title objects.
 
 setImportUploads ( $import)
 
 setLogItemCallback ( $callback)
 Sets the action to perform as each log item reached.
 
 setNoticeCallback ( $callback)
 Set a callback that displays notice messages.
 
 setNoUpdates ( $noupdates)
 Set 'no updates' mode.
 
 setPageCallback ( $callback)
 Sets the action to perform as each new page in the stream is reached.
 
 setPageOffset ( $nthPage)
 Sets 'pageOffset' value.
 
 setPageOutCallback ( $callback)
 Sets the action to perform as each page in the stream is completed.
 
 setRevisionCallback ( $callback)
 Sets the action to perform as each page revision is reached.
 
 setSiteInfoCallback ( $callback)
 Sets the action to perform when site info is encountered.
 
 setTargetNamespace ( $namespace)
 Set a target namespace to override the defaults.
 
 setTargetRootPage ( $rootpage)
 Set a target root page under which all pages are imported.
 
 setUploadCallback ( $callback)
 Sets the action to perform as each file upload version is reached.
 
 setUsernamePrefix ( $usernamePrefix, $assignKnownUsers)
 
 throwXmlError ( $err)
 
 warn ( $data)
 

Detailed Description

XML file reader for the page data importer.

implements Special:Import

Definition at line 61 of file WikiImporter.php.

Constructor & Destructor Documentation

◆ __construct()

WikiImporter::__construct ( ImportSource $source,
Authority $performer,
Config $config,
HookContainer $hookContainer,
Language $contentLanguage,
NamespaceInfo $namespaceInfo,
TitleFactory $titleFactory,
WikiPageFactory $wikiPageFactory,
UploadRevisionImporter $uploadRevisionImporter,
IContentHandlerFactory $contentHandlerFactory,
SlotRoleRegistry $slotRoleRegistry )

Creates an ImportXMLReader drawing from the source provided.

Definition at line 137 of file WikiImporter.php.

References $source, UploadSourceAdapter\registerSource(), setLogItemCallback(), setPageCallback(), setPageOutCallback(), setRevisionCallback(), and setUploadCallback().

Member Function Documentation

◆ beforeImportPage()

WikiImporter::beforeImportPage ( $titleAndForeignTitle)

Default per-page callback.

Sets up some things related to site statistics

Parameters
array$titleAndForeignTitleTwo-element array, with Title object at index 0 and ForeignTitle object at index 1
Returns
bool

Definition at line 457 of file WikiImporter.php.

◆ debug()

WikiImporter::debug ( $data)
Parameters
string$data

Definition at line 201 of file WikiImporter.php.

References wfDebug().

Referenced by doImport(), and throwXmlError().

◆ disableStatisticsUpdate()

WikiImporter::disableStatisticsUpdate ( )

Statistics update can cause a lot of time.

Since
1.29

Definition at line 447 of file WikiImporter.php.

References disableStatisticsUpdate().

Referenced by disableStatisticsUpdate(), and finishImportPage().

◆ doImport()

WikiImporter::doImport ( )

Primary entry point.

Exceptions
Exception
Returns
bool

Definition at line 675 of file WikiImporter.php.

References debug(), and warn().

◆ finishImportPage()

WikiImporter::finishImportPage ( PageIdentity $pageIdentity,
$foreignTitle,
$revCount,
$sRevCount,
$pageInfo )

Mostly for hook use.

Parameters
PageIdentity$pageIdentity
ForeignTitle$foreignTitle
int$revCount
int$sRevCount
array$pageInfo
Returns
bool

Definition at line 523 of file WikiImporter.php.

References disableStatisticsUpdate(), and wfDebug().

◆ getReader()

WikiImporter::getReader ( )
Returns
null|XMLReader

Definition at line 186 of file WikiImporter.php.

◆ importLogItem()

WikiImporter::importLogItem ( $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 500 of file WikiImporter.php.

◆ importRevision()

WikiImporter::importRevision ( $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 469 of file WikiImporter.php.

References notice().

◆ importUpload()

WikiImporter::importUpload ( $revision)

Dummy for now...

Parameters
WikiRevision$revision
Returns
bool

Definition at line 509 of file WikiImporter.php.

◆ nodeAttribute()

WikiImporter::nodeAttribute ( $attr)

Retrieves the contents of the named attribute of the current element.

Parameters
string$attrThe name of the attribute
Returns
string The value of the attribute or an empty string if it is not set in the current element.

Definition at line 638 of file WikiImporter.php.

◆ nodeContents()

WikiImporter::nodeContents ( )

Shouldn't something like this be built-in to XMLReader? Fetches text contents of the current element, assuming no sub-elements or such scary things.

Returns
string
Access: internal

Definition at line 649 of file WikiImporter.php.

◆ notice()

WikiImporter::notice ( $msg,
$params )
Parameters
string$msg
mixed...$params

Definition at line 218 of file WikiImporter.php.

References $params, wfDebug(), and wfMessage().

Referenced by importRevision().

◆ pageCallback()

WikiImporter::pageCallback ( $title)

Notify the callback function when a new "<page>" is reached.

Parameters
array$title

Definition at line 579 of file WikiImporter.php.

◆ setDebug()

WikiImporter::setDebug ( $debug)

Set debug mode...

Parameters
bool$debug

Definition at line 232 of file WikiImporter.php.

◆ setImageBasePath()

WikiImporter::setImageBasePath ( $dir)
Parameters
string$dir

Definition at line 423 of file WikiImporter.php.

◆ setImportTitleFactory()

WikiImporter::setImportTitleFactory ( $factory)

Sets the factory object to use to convert ForeignTitle objects into local Title objects.

Parameters
ImportTitleFactory$factory

Definition at line 339 of file WikiImporter.php.

Referenced by setTargetNamespace(), and setTargetRootPage().

◆ setImportUploads()

WikiImporter::setImportUploads ( $import)
Parameters
bool$import

Definition at line 430 of file WikiImporter.php.

◆ setLogItemCallback()

WikiImporter::setLogItemCallback ( $callback)

Sets the action to perform as each log item reached.

Parameters
callable$callback
Returns
callable

Definition at line 317 of file WikiImporter.php.

Referenced by __construct().

◆ setNoticeCallback()

WikiImporter::setNoticeCallback ( $callback)

Set a callback that displays notice messages.

Parameters
callable$callback
Returns
callable

Definition at line 260 of file WikiImporter.php.

References wfSetVar().

◆ setNoUpdates()

WikiImporter::setNoUpdates ( $noupdates)

Set 'no updates' mode.

In this mode, the link tables will not be updated by the importer

Parameters
bool$noupdates

Definition at line 240 of file WikiImporter.php.

◆ setPageCallback()

WikiImporter::setPageCallback ( $callback)

Sets the action to perform as each new page in the stream is reached.

Parameters
callable | null$callback
Returns
callable|null

Definition at line 269 of file WikiImporter.php.

Referenced by __construct().

◆ setPageOffset()

WikiImporter::setPageOffset ( $nthPage)

Sets 'pageOffset' value.

So it will skip the first n-1 pages and start from the nth page. It's 1-based indexing.

Parameters
int$nthPage
Since
1.29

Definition at line 250 of file WikiImporter.php.

◆ setPageOutCallback()

WikiImporter::setPageOutCallback ( $callback)

Sets the action to perform as each page in the stream is completed.

Callback accepts the page title (as a Title object), a second object with the original title form (in case it's been overridden into a local namespace), and a count of revisions.

Parameters
callable | null$callback
Returns
callable|null

Definition at line 284 of file WikiImporter.php.

Referenced by __construct().

◆ setRevisionCallback()

WikiImporter::setRevisionCallback ( $callback)

Sets the action to perform as each page revision is reached.

Parameters
callable | null$callback
Returns
callable|null

Definition at line 295 of file WikiImporter.php.

Referenced by __construct().

◆ setSiteInfoCallback()

WikiImporter::setSiteInfoCallback ( $callback)

Sets the action to perform when site info is encountered.

Parameters
callable$callback
Returns
callable

Definition at line 328 of file WikiImporter.php.

◆ setTargetNamespace()

WikiImporter::setTargetNamespace ( $namespace)

Set a target namespace to override the defaults.

Parameters
null | int$namespace
Returns
bool

Definition at line 348 of file WikiImporter.php.

References setImportTitleFactory().

Referenced by setTargetRootPage().

◆ setTargetRootPage()

WikiImporter::setTargetRootPage ( $rootpage)

Set a target root page under which all pages are imported.

Parameters
null | string$rootpage
Returns
Status

Definition at line 382 of file WikiImporter.php.

References NS_MAIN, setImportTitleFactory(), setTargetNamespace(), and wfMessage().

◆ setUploadCallback()

WikiImporter::setUploadCallback ( $callback)

Sets the action to perform as each file upload version is reached.

Parameters
callable$callback
Returns
callable

Definition at line 306 of file WikiImporter.php.

Referenced by __construct().

◆ setUsernamePrefix()

WikiImporter::setUsernamePrefix ( $usernamePrefix,
$assignKnownUsers )
Since
1.31
Parameters
string$usernamePrefixPrefix to apply to unknown (and possibly also known) usernames
bool$assignKnownUsersWhether to apply the prefix to usernames that exist locally

Definition at line 439 of file WikiImporter.php.

◆ throwXmlError()

WikiImporter::throwXmlError ( $err)
Parameters
string$err

Definition at line 193 of file WikiImporter.php.

References debug(), and wfDebug().

◆ warn()

WikiImporter::warn ( $data)
Parameters
string$data

Definition at line 210 of file WikiImporter.php.

References wfDebug().

Referenced by doImport().


The documentation for this class was generated from the following file: