MediaWiki  master
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. More...
 
 beforeImportPage ( $titleAndForeignTitle)
 Default per-page callback. More...
 
 debug ( $data)
 
 disableStatisticsUpdate ()
 Statistics update can cause a lot of time. More...
 
 doImport ()
 Primary entry point. More...
 
 finishImportPage (PageIdentity $pageIdentity, $foreignTitle, $revCount, $sRevCount, $pageInfo)
 Mostly for hook use. More...
 
 getReader ()
 
 importLogItem ( $revision)
 Default per-revision callback, performs the import. More...
 
 importRevision ( $revision)
 Default per-revision callback, performs the import. More...
 
 importUpload ( $revision)
 Dummy for now... More...
 
 nodeAttribute ( $attr)
 Retrieves the contents of the named attribute of the current element. More...
 
 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. More...
 
 notice ( $msg,... $params)
 
 pageCallback ( $title)
 Notify the callback function when a new "<page>" is reached. More...
 
 setDebug ( $debug)
 Set debug mode... More...
 
 setImageBasePath ( $dir)
 
 setImportTitleFactory ( $factory)
 Sets the factory object to use to convert ForeignTitle objects into local Title objects. More...
 
 setImportUploads ( $import)
 
 setLogItemCallback ( $callback)
 Sets the action to perform as each log item reached. More...
 
 setNoticeCallback ( $callback)
 Set a callback that displays notice messages. More...
 
 setNoUpdates ( $noupdates)
 Set 'no updates' mode. More...
 
 setPageCallback ( $callback)
 Sets the action to perform as each new page in the stream is reached. More...
 
 setPageOffset ( $nthPage)
 Sets 'pageOffset' value. More...
 
 setPageOutCallback ( $callback)
 Sets the action to perform as each page in the stream is completed. More...
 
 setRevisionCallback ( $callback)
 Sets the action to perform as each page revision is reached. More...
 
 setSiteInfoCallback ( $callback)
 Sets the action to perform when site info is encountered. More...
 
 setTargetNamespace ( $namespace)
 Set a target namespace to override the defaults. More...
 
 setTargetRootPage ( $rootpage)
 Set a target root page under which all pages are imported. More...
 
 setUploadCallback ( $callback)
 Sets the action to perform as each file upload version is reached. More...
 
 setUsernamePrefix ( $usernamePrefix, $assignKnownUsers)
 
 throwXmlError ( $err)
 
 warn ( $data)
 

Detailed Description

XML file reader for the page data importer.

implements Special:Import

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

References $title.

◆ debug()

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

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

Referenced by finishImportPage().

◆ doImport()

WikiImporter::doImport ( )

Primary entry point.

Exceptions
Exception
MWException
Returns
bool

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

References $title, DeferredUpdates\addUpdate(), Title\castFromPageIdentity(), disableStatisticsUpdate(), SiteStatsUpdate\factory(), RequestContext\getMain(), and wfDebug().

◆ getReader()

WikiImporter::getReader ( )
Returns
null|XMLReader

Definition at line 214 of file WikiImporter.php.

◆ importLogItem()

WikiImporter::importLogItem (   $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 528 of file WikiImporter.php.

◆ importRevision()

WikiImporter::importRevision (   $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 497 of file WikiImporter.php.

References notice().

◆ importUpload()

WikiImporter::importUpload (   $revision)

Dummy for now...

Parameters
WikiRevision$revision
Returns
bool

Definition at line 537 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 668 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 679 of file WikiImporter.php.

◆ notice()

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

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

References $title.

◆ setDebug()

WikiImporter::setDebug (   $debug)

Set debug mode...

Parameters
bool$debug

Definition at line 260 of file WikiImporter.php.

References $debug.

◆ setImageBasePath()

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

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

Referenced by setTargetNamespace(), and setTargetRootPage().

◆ setImportUploads()

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

Definition at line 458 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 345 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 288 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 268 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 297 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 278 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 312 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 323 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 356 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 376 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 410 of file WikiImporter.php.

References $title, Title\newFromText(), StatusValue\newGood(), 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 334 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 467 of file WikiImporter.php.

◆ throwXmlError()

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

Definition at line 221 of file WikiImporter.php.

References debug(), and wfDebug().

◆ warn()

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

Definition at line 238 of file WikiImporter.php.

References wfDebug().

Referenced by doImport().


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