MediaWiki master
MediaWiki\Import\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 58 of file WikiImporter.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ beforeImportPage()

MediaWiki\Import\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 456 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\__construct().

◆ debug()

MediaWiki\Import\WikiImporter::debug ( $data)
Parameters
string$data

Definition at line 198 of file WikiImporter.php.

References wfDebug().

Referenced by MediaWiki\Import\WikiImporter\doImport(), and MediaWiki\Import\WikiImporter\throwXmlError().

◆ disableStatisticsUpdate()

MediaWiki\Import\WikiImporter::disableStatisticsUpdate ( )

Statistics update can cause a lot of time.

Since
1.29

Definition at line 446 of file WikiImporter.php.

References MediaWiki\Import\WikiImporter\disableStatisticsUpdate().

Referenced by MediaWiki\Import\WikiImporter\disableStatisticsUpdate(), and MediaWiki\Import\WikiImporter\finishImportPage().

◆ doImport()

MediaWiki\Import\WikiImporter::doImport ( )

Primary entry point.

Exceptions

\Exception

Returns
bool

Definition at line 665 of file WikiImporter.php.

References MediaWiki\Import\WikiImporter\debug(), and MediaWiki\Import\WikiImporter\warn().

◆ finishImportPage()

MediaWiki\Import\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 522 of file WikiImporter.php.

References MediaWiki\Import\WikiImporter\disableStatisticsUpdate(), and wfDebug().

Referenced by MediaWiki\Import\WikiImporter\__construct().

◆ getReader()

MediaWiki\Import\WikiImporter::getReader ( )
Returns
null|XMLReader

Definition at line 183 of file WikiImporter.php.

◆ importLogItem()

MediaWiki\Import\WikiImporter::importLogItem ( $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 499 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\__construct().

◆ importRevision()

MediaWiki\Import\WikiImporter::importRevision ( $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 468 of file WikiImporter.php.

References MediaWiki\Import\WikiImporter\notice().

Referenced by MediaWiki\Import\WikiImporter\__construct().

◆ importUpload()

MediaWiki\Import\WikiImporter::importUpload ( $revision)

Dummy for now...

Parameters
WikiRevision$revision
Returns
bool

Definition at line 508 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\__construct().

◆ nodeAttribute()

MediaWiki\Import\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 628 of file WikiImporter.php.

◆ nodeContents()

MediaWiki\Import\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 639 of file WikiImporter.php.

◆ notice()

MediaWiki\Import\WikiImporter::notice ( $msg,
$params )
Parameters
string$msg
MessageParam|MessageSpecifier|string|int|float|list<MessageParam|MessageSpecifier|string|int|float>...$params See Message::params()

Definition at line 217 of file WikiImporter.php.

References wfDebug(), and wfMessage().

Referenced by MediaWiki\Import\WikiImporter\importRevision().

◆ pageCallback()

MediaWiki\Import\WikiImporter::pageCallback ( $title)

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

Parameters
array$title

Definition at line 575 of file WikiImporter.php.

◆ setDebug()

MediaWiki\Import\WikiImporter::setDebug ( $debug)

Set debug mode...

Parameters
bool$debug

Definition at line 231 of file WikiImporter.php.

◆ setImageBasePath()

MediaWiki\Import\WikiImporter::setImageBasePath ( $dir)
Parameters
string$dir

Definition at line 422 of file WikiImporter.php.

◆ setImportTitleFactory()

MediaWiki\Import\WikiImporter::setImportTitleFactory ( $factory)

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

Parameters
ImportTitleFactory$factory

Definition at line 338 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\setTargetNamespace(), and MediaWiki\Import\WikiImporter\setTargetRootPage().

◆ setImportUploads()

MediaWiki\Import\WikiImporter::setImportUploads ( $import)
Parameters
bool$import

Definition at line 429 of file WikiImporter.php.

◆ setLogItemCallback()

MediaWiki\Import\WikiImporter::setLogItemCallback ( $callback)

Sets the action to perform as each log item reached.

Parameters
callable$callback
Returns
callable

Definition at line 316 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\__construct(), and MediaWiki\Specials\Helpers\ImportReporter\__construct().

◆ setNoticeCallback()

MediaWiki\Import\WikiImporter::setNoticeCallback ( $callback)

Set a callback that displays notice messages.

Parameters
callable$callback
Returns
callable

Definition at line 259 of file WikiImporter.php.

References wfSetVar().

Referenced by MediaWiki\Specials\Helpers\ImportReporter\__construct().

◆ setNoUpdates()

MediaWiki\Import\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 239 of file WikiImporter.php.

◆ setPageCallback()

MediaWiki\Import\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 268 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\__construct().

◆ setPageOffset()

MediaWiki\Import\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 249 of file WikiImporter.php.

◆ setPageOutCallback()

MediaWiki\Import\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 283 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\__construct(), and MediaWiki\Specials\Helpers\ImportReporter\__construct().

◆ setRevisionCallback()

MediaWiki\Import\WikiImporter::setRevisionCallback ( $callback)

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

Parameters
callable | null$callback
Returns
callable|null

Definition at line 294 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\__construct().

◆ setSiteInfoCallback()

MediaWiki\Import\WikiImporter::setSiteInfoCallback ( $callback)

Sets the action to perform when site info is encountered.

Parameters
callable$callback
Returns
callable

Definition at line 327 of file WikiImporter.php.

◆ setTargetNamespace()

MediaWiki\Import\WikiImporter::setTargetNamespace ( $namespace)

Set a target namespace to override the defaults.

Parameters
null | int$namespace
Returns
bool

Definition at line 347 of file WikiImporter.php.

References MediaWiki\Import\WikiImporter\setImportTitleFactory().

Referenced by MediaWiki\Import\WikiImporter\setTargetRootPage().

◆ setTargetRootPage()

MediaWiki\Import\WikiImporter::setTargetRootPage ( $rootpage)

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

Parameters
null | string$rootpage
Returns
Status

Definition at line 381 of file WikiImporter.php.

References NS_MAIN, MediaWiki\Import\WikiImporter\setImportTitleFactory(), MediaWiki\Import\WikiImporter\setTargetNamespace(), and wfMessage().

◆ setUploadCallback()

MediaWiki\Import\WikiImporter::setUploadCallback ( $callback)

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

Parameters
callable$callback
Returns
callable

Definition at line 305 of file WikiImporter.php.

Referenced by MediaWiki\Import\WikiImporter\__construct().

◆ setUsernamePrefix()

MediaWiki\Import\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 438 of file WikiImporter.php.

◆ throwXmlError()

MediaWiki\Import\WikiImporter::throwXmlError ( $err)
Parameters
string$err

Definition at line 190 of file WikiImporter.php.

References MediaWiki\Import\WikiImporter\debug(), and wfDebug().

◆ warn()

MediaWiki\Import\WikiImporter::warn ( $data)
Parameters
string$data

Definition at line 207 of file WikiImporter.php.

References wfDebug().

Referenced by MediaWiki\Import\WikiImporter\doImport().


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