MediaWiki  1.27.2
WikiImporter Class Reference

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

Collaboration diagram for WikiImporter:

Public Member Functions

 __construct (ImportSource $source, Config $config=null)
 Creates an ImportXMLReader drawing from the source provided. More...
 
 beforeImportPage ($titleAndForeignTitle)
 Default per-page callback. More...
 
 debug ($data)
 
 debugRevisionHandler (&$revision)
 Alternate per-revision callback, for debugging. More...
 
 doImport ()
 Primary entry point. More...
 
 finishImportPage ($title, $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)
 
 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...
 
 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...
 
 throwXmlError ($err)
 
 warn ($data)
 

Public Attributes

 $mDebug
 
 $mImageBasePath
 
 $mPageCallback
 
 $mPageOutCallback
 
 $mRevisionCallback
 
 $mUploadCallback
 

Private Member Functions

 dumpTemp ($contents)
 
 handleContributor ()
 
 handleLogItem ()
 
 handlePage ()
 
 handleRevision (&$pageInfo)
 
 handleSiteInfo ()
 
 handleUpload (&$pageInfo)
 
 logItemCallback ($revision)
 Notify the callback function of a new log item. More...
 
 pageOutCallback ($title, $foreignTitle, $revCount, $sucCount, $pageInfo)
 Notify the callback function when a "</page>" is closed. More...
 
 processLogItem ($logInfo)
 
 processRevision ($pageInfo, $revisionInfo)
 
 processTitle ($text, $ns=null)
 
 processUpload ($pageInfo, $uploadInfo)
 
 revisionCallback ($revision)
 Notify the callback function of a revision. More...
 
 siteInfoCallback ($siteInfo)
 Notify the callback function of site info. More...
 

Private Attributes

Config $config
 
array $countableCache = []
 
 $foreignNamespaces = null
 
ImportTitleFactory $importTitleFactory
 
 $mImportUploads
 
 $mLogItemCallback
 
 $mNoticeCallback
 
 $mNoUpdates = false
 
 $mSiteInfoCallback
 
 $reader = null
 

Detailed Description

XML file reader for the page data importer.

implements Special:Import

Definition at line 33 of file WikiImporter.php.

Constructor & Destructor Documentation

WikiImporter::__construct ( ImportSource  $source,
Config  $config = null 
)

Creates an ImportXMLReader drawing from the source provided.

Parameters
ImportSource$source
Config$config
Exceptions
Exception

Definition at line 54 of file WikiImporter.php.

References $config, $status, ConfigFactory\getDefaultInstance(), UploadSourceAdapter\registerSource(), setLogItemCallback(), setPageCallback(), setPageOutCallback(), setRevisionCallback(), setUploadCallback(), and wfDeprecated().

Member Function Documentation

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

References $page, $title, and WikiPage\factory().

WikiImporter::debug (   $data)
WikiImporter::debugRevisionHandler ( $revision)

Alternate per-revision callback, for debugging.

Parameters
WikiRevision$revision

Definition at line 412 of file WikiImporter.php.

References debug().

WikiImporter::doImport ( )

Primary entry point.

Exceptions
MWException
Returns
bool

Definition at line 536 of file WikiImporter.php.

References $tag, $type, debug(), handleLogItem(), handlePage(), handleSiteInfo(), Hooks\run(), and warn().

WikiImporter::dumpTemp (   $contents)
private
Parameters
string$contents
Returns
string

Definition at line 957 of file WikiImporter.php.

References wfTempDir().

Referenced by handleUpload().

WikiImporter::finishImportPage (   $title,
  $foreignTitle,
  $revCount,
  $sRevCount,
  $pageInfo 
)

Mostly for hook use.

Parameters
Title$title
ForeignTitle$foreignTitle
int$revCount
int$sRevCount
array$pageInfo
Returns
bool

Definition at line 377 of file WikiImporter.php.

References $args, $content, $page, $title, DeferredUpdates\addUpdate(), SiteStatsUpdate\factory(), WikiPage\factory(), Hooks\run(), and wfDebug().

WikiImporter::getReader ( )
Returns
null|XMLReader

Definition at line 100 of file WikiImporter.php.

References $reader.

WikiImporter::handleContributor ( )
private
Returns
array

Definition at line 1005 of file WikiImporter.php.

References $tag, and nodeContents().

Referenced by handleLogItem(), handleRevision(), and handleUpload().

WikiImporter::handleLogItem ( )
private

Definition at line 626 of file WikiImporter.php.

References $tag, debug(), handleContributor(), nodeContents(), processLogItem(), Hooks\run(), and warn().

Referenced by doImport().

WikiImporter::handlePage ( )
private
WikiImporter::handleRevision ( $pageInfo)
private
Parameters
array$pageInfo

Definition at line 786 of file WikiImporter.php.

References $tag, debug(), handleContributor(), nodeContents(), processRevision(), Hooks\run(), and warn().

Referenced by handlePage().

WikiImporter::handleSiteInfo ( )
private

Definition at line 599 of file WikiImporter.php.

References $foreignNamespaces, $tag, debug(), nodeAttribute(), nodeContents(), and siteInfoCallback().

Referenced by doImport().

WikiImporter::handleUpload ( $pageInfo)
private
Parameters
array$pageInfo
Returns
mixed

Definition at line 902 of file WikiImporter.php.

References $path, $tag, debug(), dumpTemp(), handleContributor(), nodeContents(), processUpload(), Hooks\run(), and warn().

Referenced by handlePage().

WikiImporter::importLogItem (   $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 353 of file WikiImporter.php.

References DB_MASTER, and wfGetDB().

WikiImporter::importRevision (   $revision)

Default per-revision callback, performs the import.

Parameters
WikiRevision$revision
Returns
bool

Definition at line 323 of file WikiImporter.php.

References DB_MASTER, notice(), and wfGetDB().

WikiImporter::importUpload (   $revision)

Dummy for now...

Parameters
WikiRevision$revision
Returns
bool

Definition at line 363 of file WikiImporter.php.

References DB_MASTER, and wfGetDB().

WikiImporter::logItemCallback (   $revision)
private

Notify the callback function of a new log item.

Parameters
WikiRevision$revision
Returns
bool|mixed

Definition at line 484 of file WikiImporter.php.

Referenced by processLogItem().

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

Referenced by handlePage(), and handleSiteInfo().

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:
private

Definition at line 510 of file WikiImporter.php.

References $buffer.

Referenced by handleContributor(), handleLogItem(), handlePage(), handleRevision(), handleSiteInfo(), and handleUpload().

WikiImporter::notice (   $msg)

Definition at line 119 of file WikiImporter.php.

References $params, and wfMessage().

Referenced by importRevision(), and processTitle().

WikiImporter::pageCallback (   $title)

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

Parameters
Title$title

Definition at line 443 of file WikiImporter.php.

References $title.

Referenced by handlePage().

WikiImporter::pageOutCallback (   $title,
  $foreignTitle,
  $revCount,
  $sucCount,
  $pageInfo 
)
private

Notify the callback function when a "</page>" is closed.

Parameters
Title$title
ForeignTitle$foreignTitle
int$revCount
int$sucCountNumber of revisions for which callback returned true
array$pageInfoAssociative array of page information

Definition at line 457 of file WikiImporter.php.

References $args.

Referenced by handlePage().

WikiImporter::processLogItem (   $logInfo)
private
Parameters
array$logInfo
Returns
bool|mixed

Definition at line 662 of file WikiImporter.php.

References logItemCallback(), and Title\newFromText().

Referenced by handleLogItem().

WikiImporter::processRevision (   $pageInfo,
  $revisionInfo 
)
private
Parameters
array$pageInfo
array$revisionInfo
Returns
bool|mixed

Definition at line 827 of file WikiImporter.php.

References $handler, $wgMaxArticleSize, global, revisionCallback(), and wfTimestampNow().

Referenced by handleRevision().

WikiImporter::processTitle (   $text,
  $ns = null 
)
private
Parameters
string$text
string | null$ns
Returns
array|bool

Definition at line 1033 of file WikiImporter.php.

References $title, and notice().

Referenced by handlePage().

WikiImporter::processUpload (   $pageInfo,
  $uploadInfo 
)
private
Parameters
array$pageInfo
array$uploadInfo
Returns
mixed

Definition at line 968 of file WikiImporter.php.

Referenced by handleUpload().

WikiImporter::revisionCallback (   $revision)
private

Notify the callback function of a revision.

Parameters
WikiRevision$revision
Returns
bool|mixed

Definition at line 470 of file WikiImporter.php.

Referenced by processRevision().

WikiImporter::setDebug (   $debug)

Set debug mode...

Parameters
bool$debug

Definition at line 134 of file WikiImporter.php.

References $debug.

Referenced by ImportLinkCacheIntegrationTest\doImport().

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

Definition at line 294 of file WikiImporter.php.

References $dir.

WikiImporter::setImportTitleFactory (   $factory)

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

Parameters
ImportTitleFactory$factory

Definition at line 231 of file WikiImporter.php.

References $factory.

Referenced by setTargetNamespace(), and setTargetRootPage().

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

Definition at line 301 of file WikiImporter.php.

WikiImporter::setLogItemCallback (   $callback)

Sets the action to perform as each log item reached.

Parameters
callable$callback
Returns
callable

Definition at line 209 of file WikiImporter.php.

References $mLogItemCallback.

Referenced by __construct().

WikiImporter::setNoticeCallback (   $callback)

Set a callback that displays notice messages.

Parameters
callable$callback
Returns
callable

Definition at line 152 of file WikiImporter.php.

References wfSetVar().

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

WikiImporter::setPageCallback (   $callback)

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

Parameters
callable$callback
Returns
callable

Definition at line 161 of file WikiImporter.php.

References $mPageCallback.

Referenced by __construct().

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$callback
Returns
callable

Definition at line 176 of file WikiImporter.php.

References $mPageOutCallback.

Referenced by __construct().

WikiImporter::setRevisionCallback (   $callback)

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

Parameters
callable$callback
Returns
callable

Definition at line 187 of file WikiImporter.php.

References $mRevisionCallback.

Referenced by __construct().

WikiImporter::setSiteInfoCallback (   $callback)

Sets the action to perform when site info is encountered.

Parameters
callable$callback
Returns
callable

Definition at line 220 of file WikiImporter.php.

References $mSiteInfoCallback.

WikiImporter::setTargetNamespace (   $namespace)

Set a target namespace to override the defaults.

Parameters
null | int$namespace
Returns
bool

Definition at line 240 of file WikiImporter.php.

References MWNamespace\exists(), and setImportTitleFactory().

Referenced by SpecialImport\doImport(), ApiImport\execute(), and setTargetRootPage().

WikiImporter::setTargetRootPage (   $rootpage)

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

Parameters
null | string$rootpage
Returns
Status

Definition at line 262 of file WikiImporter.php.

References $status, $title, $wgContLang, global, MWNamespace\hasSubpages(), Title\newFromText(), Status\newGood(), NS_MAIN, setImportTitleFactory(), setTargetNamespace(), and wfMessage().

WikiImporter::setUploadCallback (   $callback)

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

Parameters
callable$callback
Returns
callable

Definition at line 198 of file WikiImporter.php.

References $mUploadCallback.

Referenced by __construct().

WikiImporter::siteInfoCallback (   $siteInfo)
private

Notify the callback function of site info.

Parameters
array$siteInfo
Returns
bool|mixed

Definition at line 430 of file WikiImporter.php.

Referenced by handleSiteInfo().

WikiImporter::throwXmlError (   $err)

Definition at line 104 of file WikiImporter.php.

References debug(), and wfDebug().

WikiImporter::warn (   $data)

Definition at line 115 of file WikiImporter.php.

References wfDebug().

Referenced by doImport(), handleLogItem(), handlePage(), handleRevision(), and handleUpload().

Member Data Documentation

Config WikiImporter::$config
private

Definition at line 42 of file WikiImporter.php.

Referenced by __construct().

array WikiImporter::$countableCache = []
private

Definition at line 46 of file WikiImporter.php.

WikiImporter::$foreignNamespaces = null
private

Definition at line 35 of file WikiImporter.php.

Referenced by handleSiteInfo().

ImportTitleFactory WikiImporter::$importTitleFactory
private

Definition at line 44 of file WikiImporter.php.

WikiImporter::$mDebug

Definition at line 38 of file WikiImporter.php.

WikiImporter::$mImageBasePath

Definition at line 39 of file WikiImporter.php.

WikiImporter::$mImportUploads
private

Definition at line 39 of file WikiImporter.php.

WikiImporter::$mLogItemCallback
private

Definition at line 36 of file WikiImporter.php.

Referenced by setLogItemCallback().

WikiImporter::$mNoticeCallback
private

Definition at line 38 of file WikiImporter.php.

WikiImporter::$mNoUpdates = false
private

Definition at line 40 of file WikiImporter.php.

WikiImporter::$mPageCallback

Definition at line 36 of file WikiImporter.php.

Referenced by setPageCallback().

WikiImporter::$mPageOutCallback

Definition at line 37 of file WikiImporter.php.

Referenced by setPageOutCallback().

WikiImporter::$mRevisionCallback

Definition at line 36 of file WikiImporter.php.

Referenced by setRevisionCallback().

WikiImporter::$mSiteInfoCallback
private

Definition at line 37 of file WikiImporter.php.

Referenced by setSiteInfoCallback().

WikiImporter::$mUploadCallback

Definition at line 36 of file WikiImporter.php.

Referenced by setUploadCallback().

WikiImporter::$reader = null
private

Definition at line 34 of file WikiImporter.php.

Referenced by getReader().


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