MediaWiki master
MediaWiki\Import\WikiImporter Class Reference

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

Public Member Functions

 __construct (ImportSource $source, Authority $performer, private readonly Config $config, HookContainer $hookContainer, private readonly Language $contentLanguage, private readonly NamespaceInfo $namespaceInfo, private readonly TitleFactory $titleFactory, private readonly WikiPageFactory $wikiPageFactory, private readonly UploadRevisionImporter $uploadRevisionImporter, private readonly IContentHandlerFactory $contentHandlerFactory, private readonly 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 ()
 
 getReauthOperation ()
 Re-authentication helper method.
 
 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.
 
 setAuthorizeOnly (bool $authorizeOnly)
 Re-authentication helper method.
 
 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 60 of file WikiImporter.php.

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ beforeImportPage()

MediaWiki\Import\WikiImporter::beforeImportPage ( $titleAndForeignTitle)

Default per-page callback.

Sets up some things related to site statistics

Parameters
array{0:Title,1:ForeignTitle}$titleAndForeignTitle
Returns
bool

Definition at line 448 of file WikiImporter.php.

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

◆ debug()

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

Definition at line 191 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 439 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 667 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 524 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 176 of file WikiImporter.php.

◆ getReauthOperation()

MediaWiki\Import\WikiImporter::getReauthOperation ( )

Re-authentication helper method.

Definition at line 1363 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 495 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 460 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 507 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 630 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 641 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 210 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 577 of file WikiImporter.php.

◆ setAuthorizeOnly()

MediaWiki\Import\WikiImporter::setAuthorizeOnly ( bool $authorizeOnly)

Re-authentication helper method.

Definition at line 1370 of file WikiImporter.php.

◆ setDebug()

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

Set debug mode...

Parameters
bool$debug

Definition at line 224 of file WikiImporter.php.

◆ setImageBasePath()

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

Definition at line 415 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 331 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 422 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 309 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 252 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 232 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 261 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 242 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 276 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 287 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 320 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 340 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 374 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 298 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 431 of file WikiImporter.php.

◆ throwXmlError()

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

Definition at line 183 of file WikiImporter.php.

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

◆ warn()

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

Definition at line 200 of file WikiImporter.php.

References wfDebug().

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


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