MediaWiki REL1_39
WikiImporter Class Reference

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

Public Member Functions

 __construct (ImportSource $source, Config $config, HookContainer $hookContainer, Language $contentLanguage, NamespaceInfo $namespaceInfo, TitleFactory $titleFactory, WikiPageFactory $wikiPageFactory, UploadRevisionImporter $uploadRevisionImporter, PermissionManager $permissionManager, 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 46 of file WikiImporter.php.

Constructor & Destructor Documentation

◆ __construct()

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

Creates an ImportXMLReader drawing from the source provided.

Parameters
ImportSource$source
Config$config
HookContainer$hookContainer
Language$contentLanguage
NamespaceInfo$namespaceInfo
TitleFactory$titleFactory
WikiPageFactory$wikiPageFactory
UploadRevisionImporter$uploadRevisionImporter
PermissionManager$permissionManager
IContentHandlerFactory$contentHandlerFactory
SlotRoleRegistry$slotRoleRegistry
Exceptions
MWException

Definition at line 147 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 495 of file WikiImporter.php.

References $title.

◆ debug()

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

Definition at line 239 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 485 of file WikiImporter.php.

References disableStatisticsUpdate().

Referenced by disableStatisticsUpdate(), and finishImportPage().

◆ doImport()

WikiImporter::doImport ( )

Primary entry point.

Exceptions
Exception
MWException
Returns
bool

Definition at line 716 of file WikiImporter.php.

References $type, 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 561 of file WikiImporter.php.

References $title, disableStatisticsUpdate(), and wfDebug().

◆ getReader()

WikiImporter::getReader ( )
Returns
null|XMLReader

Definition at line 224 of file WikiImporter.php.

◆ importLogItem()

WikiImporter::importLogItem ( $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 538 of file WikiImporter.php.

◆ importRevision()

WikiImporter::importRevision ( $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 507 of file WikiImporter.php.

References notice().

◆ importUpload()

WikiImporter::importUpload ( $revision)

Dummy for now...

Parameters
WikiRevision$revision
Returns
bool

Definition at line 547 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 678 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 689 of file WikiImporter.php.

◆ notice()

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

Definition at line 256 of file WikiImporter.php.

References 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 619 of file WikiImporter.php.

References $title.

◆ setDebug()

WikiImporter::setDebug ( $debug)

Set debug mode...

Parameters
bool$debug

Definition at line 270 of file WikiImporter.php.

References $debug.

◆ setImageBasePath()

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

Definition at line 461 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 377 of file WikiImporter.php.

Referenced by setTargetNamespace(), and setTargetRootPage().

◆ setImportUploads()

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

Definition at line 468 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 355 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 298 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 278 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 307 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 288 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 322 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 333 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 366 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 386 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 420 of file WikiImporter.php.

References $title, 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 344 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 477 of file WikiImporter.php.

◆ throwXmlError()

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

Definition at line 231 of file WikiImporter.php.

References debug(), and wfDebug().

◆ warn()

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

Definition at line 248 of file WikiImporter.php.

References wfDebug().

Referenced by doImport().


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