38 use Wikimedia\NormalizedException\NormalizedException;
51 private $foreignNamespaces =
null;
54 private $mLogItemCallback;
57 private $mUploadCallback;
60 private $mRevisionCallback;
63 private $mPageCallback;
66 private $mSiteInfoCallback;
69 private $mPageOutCallback;
72 private $mNoticeCallback;
78 private $mImportUploads;
81 private $mImageBasePath;
84 private $mNoUpdates =
false;
87 private $pageOffset = 0;
93 private $importTitleFactory;
99 private $countableCache = [];
102 private $disableStatisticsUpdate =
false;
105 private $externalUserNames;
108 private $contentLanguage;
111 private $namespaceInfo;
114 private $titleFactory;
117 private $wikiPageFactory;
120 private $uploadRevisionImporter;
123 private $permissionManager;
126 private $contentHandlerFactory;
129 private $slotRoleRegistry;
159 $this->reader =
new XMLReader();
160 $this->config = $config;
161 $this->hookRunner =
new HookRunner( $hookContainer );
162 $this->contentLanguage = $contentLanguage;
163 $this->namespaceInfo = $namespaceInfo;
164 $this->titleFactory = $titleFactory;
165 $this->wikiPageFactory = $wikiPageFactory;
166 $this->uploadRevisionImporter = $uploadRevisionImporter;
167 $this->permissionManager = $permissionManager;
168 $this->contentHandlerFactory = $contentHandlerFactory;
169 $this->slotRoleRegistry = $slotRoleRegistry;
171 if ( !in_array(
'uploadsource', stream_get_wrappers() ) ) {
172 stream_wrapper_register(
'uploadsource', UploadSourceAdapter::class );
179 $oldDisable = @libxml_disable_entity_loader(
false );
180 if ( defined(
'LIBXML_PARSEHUGE' ) ) {
181 $status = $this->reader->open(
"uploadsource://$id",
null, LIBXML_PARSEHUGE );
183 $status = $this->reader->open(
"uploadsource://$id" );
186 $error = libxml_get_last_error();
188 @libxml_disable_entity_loader( $oldDisable );
189 throw new MWException(
'Encountered an internal error while initializing WikiImporter object: ' .
193 @libxml_disable_entity_loader( $oldDisable );
203 $this->contentLanguage,
204 $this->namespaceInfo,
214 return $this->reader;
221 $this->
debug(
"FAILURE: $err" );
222 wfDebug(
"WikiImporter XML error: $err" );
229 if ( $this->mDebug ) {
237 public function warn( $data ) {
245 public function notice( $msg, ...$params ) {
246 if ( is_callable( $this->mNoticeCallback ) ) {
247 call_user_func( $this->mNoticeCallback, $msg, $params );
268 $this->mNoUpdates = $noupdates;
278 $this->pageOffset = $nthPage;
288 return wfSetVar( $this->mNoticeCallback, $callback );
297 $previous = $this->mPageCallback;
298 $this->mPageCallback = $callback;
312 $previous = $this->mPageOutCallback;
313 $this->mPageOutCallback = $callback;
323 $previous = $this->mRevisionCallback;
324 $this->mRevisionCallback = $callback;
334 $previous = $this->mUploadCallback;
335 $this->mUploadCallback = $callback;
345 $previous = $this->mLogItemCallback;
346 $this->mLogItemCallback = $callback;
356 $previous = $this->mSiteInfoCallback;
357 $this->mSiteInfoCallback = $callback;
367 $this->importTitleFactory = $factory;
376 if ( $namespace ===
null ) {
380 $this->contentLanguage,
381 $this->namespaceInfo,
388 $this->namespaceInfo->exists( intval( $namespace ) )
390 $namespace = intval( $namespace );
393 $this->namespaceInfo,
411 $nsInfo = $this->namespaceInfo;
412 if ( $rootpage ===
null ) {
416 $this->contentLanguage,
421 } elseif ( $rootpage !==
'' ) {
422 $rootpage = rtrim( $rootpage,
'/' );
426 $status->fatal(
'import-rootpage-invalid' );
427 } elseif ( !$nsInfo->hasSubpages(
$title->getNamespace() ) ) {
430 : $this->contentLanguage->getNsText(
$title->getNamespace() );
431 $status->fatal(
'import-rootpage-nosubpage', $displayNSText );
451 $this->mImageBasePath = $dir;
458 $this->mImportUploads = $import;
467 $this->externalUserNames =
new ExternalUserNames( $usernamePrefix, $assignKnownUsers );
485 $title = $titleAndForeignTitle[0];
486 $page = $this->wikiPageFactory->newFromTitle(
$title );
487 $this->countableCache[
'title_' .
$title->getPrefixedText()] = $page->isCountable();
497 if ( !$revision->getContentHandler()->canBeUsedOn( $revision->getTitle() ) ) {
498 $this->
notice(
'import-error-bad-location',
499 $revision->getTitle()->getPrefixedText(),
501 $revision->getModel(),
502 $revision->getFormat()
509 return $revision->importOldRevision();
511 $this->
notice(
'import-error-unserialize',
512 $revision->getTitle()->getPrefixedText(),
514 $revision->getModel(),
515 $revision->getFormat()
528 return $revision->importLogItem();
537 $status = $this->uploadRevisionImporter->import( $revision );
538 return $status->isGood();
551 $sRevCount, $pageInfo
560 $page = $this->wikiPageFactory->newFromTitle( $pageIdentity );
562 $page->loadPageData( WikiPage::READ_LATEST );
563 $rev = $page->getRevisionRecord();
564 if ( $rev ===
null ) {
566 wfDebug( __METHOD__ .
': Skipping article count adjustment for ' . $pageIdentity .
567 ' because WikiPage::getRevisionRecord() returned null' );
570 $update = $page->newPageUpdater( $user )->prepareUpdate();
571 $countKey =
'title_' . CacheKeyHelper::getKeyForPage( $pageIdentity );
572 $countable = $update->isCountable();
573 if ( array_key_exists( $countKey, $this->countableCache ) &&
574 $countable != $this->countableCache[$countKey] ) {
576 'articles' => ( (
int)$countable - (
int)$this->countableCache[$countKey] )
584 return $this->hookRunner->onAfterImportPage(
$title, $foreignTitle,
585 $revCount, $sRevCount, $pageInfo );
593 private function siteInfoCallback( $siteInfo ) {
594 if ( isset( $this->mSiteInfoCallback ) ) {
595 return call_user_func_array(
596 $this->mSiteInfoCallback,
609 if ( isset( $this->mPageCallback ) ) {
610 call_user_func( $this->mPageCallback,
$title );
622 private function pageOutCallback(
PageIdentity $pageIdentity, $foreignTitle, $revCount,
623 $sucCount, $pageInfo ) {
624 if ( isset( $this->mPageOutCallback ) ) {
625 call_user_func_array( $this->mPageOutCallback, func_get_args() );
634 private function revisionCallback( $revision ) {
635 if ( isset( $this->mRevisionCallback ) ) {
636 return call_user_func_array(
637 $this->mRevisionCallback,
650 private function logItemCallback( $revision ) {
651 if ( isset( $this->mLogItemCallback ) ) {
652 return call_user_func_array(
653 $this->mLogItemCallback,
668 return $this->reader->getAttribute( $attr ) ??
'';
679 if ( $this->reader->isEmptyElement ) {
683 while ( $this->reader->read() ) {
684 switch ( $this->reader->nodeType ) {
685 case XMLReader::TEXT:
686 case XMLReader::CDATA:
687 case XMLReader::SIGNIFICANT_WHITESPACE:
688 $buffer .= $this->reader->value;
690 case XMLReader::END_ELEMENT:
695 $this->reader->close();
710 $oldDisable = @libxml_disable_entity_loader(
true );
712 $this->reader->read();
714 if ( $this->reader->localName !=
'mediawiki' ) {
716 @libxml_disable_entity_loader( $oldDisable );
717 $error = libxml_get_last_error();
719 throw new NormalizedException(
"XML error at line {line}: {message}", [
720 'line' => $error->line,
721 'message' => $error->message,
724 throw new MWException(
"Expected <mediawiki> tag, got " .
725 $this->reader->localName );
728 $this->
debug(
"<mediawiki> tag is correct." );
730 $this->
debug(
"Starting primary dump processing loop." );
732 $keepReading = $this->reader->read();
735 while ( $keepReading ) {
736 $tag = $this->reader->localName;
737 if ( $this->pageOffset ) {
738 if ( $tag ===
'page' ) {
741 if ( $pageCount < $this->pageOffset ) {
742 $keepReading = $this->reader->next();
746 $type = $this->reader->nodeType;
748 if ( !$this->hookRunner->onImportHandleToplevelXMLTag( $this ) ) {
750 } elseif ( $tag ==
'mediawiki' &&
$type == XMLReader::END_ELEMENT ) {
752 } elseif ( $tag ==
'siteinfo' ) {
753 $this->handleSiteInfo();
754 } elseif ( $tag ==
'page' ) {
756 } elseif ( $tag ==
'logitem' ) {
757 $this->handleLogItem();
758 } elseif ( $tag !=
'#text' ) {
759 $this->
warn(
"Unhandled top-level XML tag $tag" );
765 $keepReading = $this->reader->next();
767 $this->
debug(
"Skip" );
769 $keepReading = $this->reader->read();
774 @libxml_disable_entity_loader( $oldDisable );
775 $this->reader->close();
781 private function handleSiteInfo() {
782 $this->
debug(
"Enter site info handler." );
786 $normalFields = [
'sitename',
'base',
'generator',
'case' ];
788 while ( $this->reader->read() ) {
789 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
790 $this->reader->localName ==
'siteinfo' ) {
794 $tag = $this->reader->localName;
796 if ( $tag ==
'namespace' ) {
799 } elseif ( in_array( $tag, $normalFields ) ) {
804 $siteInfo[
'_namespaces'] = $this->foreignNamespaces;
805 $this->siteInfoCallback( $siteInfo );
808 private function handleLogItem() {
809 $this->
debug(
"Enter log item handler." );
813 $normalFields = [
'id',
'comment',
'type',
'action',
'timestamp',
814 'logtitle',
'params' ];
816 while ( $this->reader->read() ) {
817 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
818 $this->reader->localName ==
'logitem' ) {
822 $tag = $this->reader->localName;
824 if ( !$this->hookRunner->onImportHandleLogItemXMLTag( $this, $logInfo ) ) {
826 } elseif ( in_array( $tag, $normalFields ) ) {
828 } elseif ( $tag ==
'contributor' ) {
829 $logInfo[
'contributor'] = $this->handleContributor();
830 } elseif ( $tag !=
'#text' ) {
831 $this->
warn(
"Unhandled log-item XML tag $tag" );
835 $this->processLogItem( $logInfo );
842 private function processLogItem( $logInfo ) {
845 if ( isset( $logInfo[
'id'] ) ) {
846 $revision->setID( $logInfo[
'id'] );
848 $revision->setType( $logInfo[
'type'] );
849 $revision->setAction( $logInfo[
'action'] );
850 if ( isset( $logInfo[
'timestamp'] ) ) {
851 $revision->setTimestamp( $logInfo[
'timestamp'] );
853 if ( isset( $logInfo[
'params'] ) ) {
854 $revision->setParams( $logInfo[
'params'] );
856 if ( isset( $logInfo[
'logtitle'] ) ) {
862 $revision->setNoUpdates( $this->mNoUpdates );
864 if ( isset( $logInfo[
'comment'] ) ) {
865 $revision->setComment( $logInfo[
'comment'] );
868 if ( isset( $logInfo[
'contributor'][
'username'] ) ) {
869 $revision->setUsername(
870 $this->externalUserNames->applyPrefix( $logInfo[
'contributor'][
'username'] )
872 } elseif ( isset( $logInfo[
'contributor'][
'ip'] ) ) {
873 $revision->setUserIP( $logInfo[
'contributor'][
'ip'] );
875 $revision->setUsername( $this->externalUserNames->addPrefix(
'Unknown user' ) );
878 return $this->logItemCallback( $revision );
881 private function handlePage() {
883 $this->
debug(
"Enter page handler." );
884 $pageInfo = [
'revisionCount' => 0,
'successfulRevisionCount' => 0 ];
887 $normalFields = [
'title',
'ns',
'id',
'redirect',
'restrictions' ];
892 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
893 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
894 $this->reader->localName ==
'page' ) {
900 $tag = $this->reader->localName;
905 } elseif ( !$this->hookRunner->onImportHandlePageXMLTag( $this, $pageInfo ) ) {
907 } elseif ( in_array( $tag, $normalFields ) ) {
915 if ( $tag ==
'redirect' ) {
920 } elseif ( $tag ==
'revision' || $tag ==
'upload' ) {
922 $title = $this->processTitle( $pageInfo[
'title'],
923 $pageInfo[
'ns'] ??
null );
926 if ( is_array(
$title ) ) {
928 list( $pageInfo[
'_title'], $foreignTitle ) =
$title;
936 if ( $tag ==
'revision' ) {
937 $this->handleRevision( $pageInfo );
939 $this->handleUpload( $pageInfo );
942 } elseif ( $tag !=
'#text' ) {
943 $this->
warn(
"Unhandled page XML tag $tag" );
953 if ( array_key_exists(
'_title', $pageInfo ) ) {
955 $title = $pageInfo[
'_title'];
956 $this->pageOutCallback(
960 $pageInfo[
'revisionCount'],
961 $pageInfo[
'successfulRevisionCount'],
970 private function handleRevision( &$pageInfo ) {
971 $this->
debug(
"Enter revision handler" );
974 $normalFields = [
'id',
'parentid',
'timestamp',
'comment',
'minor',
'origin',
975 'model',
'format',
'text',
'sha1' ];
979 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
980 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
981 $this->reader->localName ==
'revision' ) {
985 $tag = $this->reader->localName;
987 if ( !$this->hookRunner->onImportHandleRevisionXMLTag(
988 $this, $pageInfo, $revisionInfo )
991 } elseif ( in_array( $tag, $normalFields ) ) {
993 } elseif ( $tag ==
'content' ) {
995 $revisionInfo[$tag][] = $this->handleContent();
996 } elseif ( $tag ==
'contributor' ) {
997 $revisionInfo[
'contributor'] = $this->handleContributor();
998 } elseif ( $tag !=
'#text' ) {
999 $this->
warn(
"Unhandled revision XML tag $tag" );
1004 $pageInfo[
'revisionCount']++;
1005 if ( $this->processRevision( $pageInfo, $revisionInfo ) ) {
1006 $pageInfo[
'successfulRevisionCount']++;
1010 private function handleContent() {
1011 $this->
debug(
"Enter content handler" );
1014 $normalFields = [
'role',
'origin',
'model',
'format',
'text' ];
1018 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
1019 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
1020 $this->reader->localName ==
'content' ) {
1024 $tag = $this->reader->localName;
1026 if ( !$this->hookRunner->onImportHandleContentXMLTag(
1027 $this, $contentInfo )
1030 } elseif ( in_array( $tag, $normalFields ) ) {
1032 } elseif ( $tag !=
'#text' ) {
1033 $this->
warn(
"Unhandled content XML tag $tag" );
1038 return $contentInfo;
1049 private function makeContent(
Title $title, $revisionId, $contentInfo ) {
1050 $maxArticleSize = MediaWikiServices::getInstance()->getMainConfig()->get(
1051 MainConfigNames::MaxArticleSize );
1053 if ( !isset( $contentInfo[
'text'] ) ) {
1054 throw new MWException(
'Missing text field in import.' );
1061 if ( ( !isset( $contentInfo[
'model'] ) ||
1062 in_array( $contentInfo[
'model'], [
1070 strlen( $contentInfo[
'text'] ) > $maxArticleSize * 1024
1074 "the revision with ID $revisionId" :
1076 ) .
" exceeds the maximum allowable size ({$maxArticleSize} KiB)" );
1079 $role = $contentInfo[
'role'] ?? SlotRecord::MAIN;
1080 $model = $contentInfo[
'model'] ?? $this->getDefaultContentModel(
$title, $role );
1081 $handler = $this->getContentHandler( $model );
1083 $text = $handler->importTransform( $contentInfo[
'text'] );
1085 return $handler->unserializeContent( $text );
1094 private function processRevision( $pageInfo, $revisionInfo ) {
1097 $revId = $revisionInfo[
'id'] ?? 0;
1099 $revision->setID( $revisionInfo[
'id'] );
1102 $title = $pageInfo[
'_title'];
1103 $revision->setTitle(
$title );
1106 $revision->setContent( SlotRecord::MAIN,
$content );
1108 foreach ( $revisionInfo[
'content'] ?? [] as $slotInfo ) {
1109 if ( !isset( $slotInfo[
'role'] ) ) {
1110 throw new MWException(
"Missing role for imported slot." );
1114 $revision->setContent( $slotInfo[
'role'],
$content );
1116 $revision->setTimestamp( $revisionInfo[
'timestamp'] ??
wfTimestampNow() );
1118 if ( isset( $revisionInfo[
'comment'] ) ) {
1119 $revision->setComment( $revisionInfo[
'comment'] );
1122 if ( isset( $revisionInfo[
'minor'] ) ) {
1123 $revision->setMinor(
true );
1125 if ( isset( $revisionInfo[
'contributor'][
'username'] ) ) {
1126 $revision->setUsername(
1127 $this->externalUserNames->applyPrefix( $revisionInfo[
'contributor'][
'username'] )
1129 } elseif ( isset( $revisionInfo[
'contributor'][
'ip'] ) ) {
1130 $revision->setUserIP( $revisionInfo[
'contributor'][
'ip'] );
1132 $revision->setUsername( $this->externalUserNames->addPrefix(
'Unknown user' ) );
1134 if ( isset( $revisionInfo[
'sha1'] ) ) {
1135 $revision->setSha1Base36( $revisionInfo[
'sha1'] );
1137 $revision->setNoUpdates( $this->mNoUpdates );
1139 return $this->revisionCallback( $revision );
1146 private function handleUpload( &$pageInfo ) {
1147 $this->
debug(
"Enter upload handler" );
1150 $normalFields = [
'timestamp',
'comment',
'filename',
'text',
1151 'src',
'size',
'sha1base36',
'archivename',
'rel' ];
1155 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
1156 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
1157 $this->reader->localName ==
'upload' ) {
1161 $tag = $this->reader->localName;
1163 if ( !$this->hookRunner->onImportHandleUploadXMLTag( $this, $pageInfo ) ) {
1165 } elseif ( in_array( $tag, $normalFields ) ) {
1167 } elseif ( $tag ==
'contributor' ) {
1168 $uploadInfo[
'contributor'] = $this->handleContributor();
1169 } elseif ( $tag ==
'contents' ) {
1171 $encoding = $this->reader->getAttribute(
'encoding' );
1172 if ( $encoding ===
'base64' ) {
1173 $uploadInfo[
'fileSrc'] = $this->dumpTemp( base64_decode( $contents ) );
1174 $uploadInfo[
'isTempSrc'] =
true;
1176 } elseif ( $tag !=
'#text' ) {
1177 $this->
warn(
"Unhandled upload XML tag $tag" );
1182 if ( $this->mImageBasePath && isset( $uploadInfo[
'rel'] ) ) {
1183 $path =
"{$this->mImageBasePath}/{$uploadInfo['rel']}";
1184 if ( file_exists(
$path ) ) {
1185 $uploadInfo[
'fileSrc'] =
$path;
1186 $uploadInfo[
'isTempSrc'] =
false;
1190 if ( $this->mImportUploads ) {
1191 return $this->processUpload( $pageInfo, $uploadInfo );
1199 private function dumpTemp( $contents ) {
1200 $filename = tempnam(
wfTempDir(),
'importupload' );
1201 file_put_contents( $filename, $contents );
1210 private function processUpload( $pageInfo, $uploadInfo ) {
1212 $revId = $pageInfo[
'id'];
1213 $title = $pageInfo[
'_title'];
1216 $revision->setTitle(
$title );
1217 $revision->setID( $revId );
1218 $revision->setTimestamp( $uploadInfo[
'timestamp'] );
1219 $revision->setContent( SlotRecord::MAIN,
$content );
1220 $revision->setFilename( $uploadInfo[
'filename'] );
1221 if ( isset( $uploadInfo[
'archivename'] ) ) {
1222 $revision->setArchiveName( $uploadInfo[
'archivename'] );
1224 $revision->setSrc( $uploadInfo[
'src'] );
1225 if ( isset( $uploadInfo[
'fileSrc'] ) ) {
1226 $revision->setFileSrc( $uploadInfo[
'fileSrc'],
1227 !empty( $uploadInfo[
'isTempSrc'] )
1230 if ( isset( $uploadInfo[
'sha1base36'] ) ) {
1231 $revision->setSha1Base36( $uploadInfo[
'sha1base36'] );
1233 $revision->setSize( intval( $uploadInfo[
'size'] ) );
1234 $revision->setComment( $uploadInfo[
'comment'] );
1236 if ( isset( $uploadInfo[
'contributor'][
'username'] ) ) {
1237 $revision->setUsername(
1238 $this->externalUserNames->applyPrefix( $uploadInfo[
'contributor'][
'username'] )
1240 } elseif ( isset( $uploadInfo[
'contributor'][
'ip'] ) ) {
1241 $revision->setUserIP( $uploadInfo[
'contributor'][
'ip'] );
1243 $revision->setNoUpdates( $this->mNoUpdates );
1245 return call_user_func( $this->mUploadCallback, $revision );
1251 private function handleContributor() {
1252 $this->
debug(
"Enter contributor handler." );
1254 if ( $this->reader->isEmptyElement ) {
1258 $fields = [
'id',
'ip',
'username' ];
1261 while ( $this->reader->read() ) {
1262 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
1263 $this->reader->localName ==
'contributor' ) {
1267 $tag = $this->reader->localName;
1269 if ( in_array( $tag, $fields ) ) {
1282 private function processTitle( $text, $ns =
null ) {
1283 if ( $this->foreignNamespaces ===
null ) {
1285 $this->contentLanguage
1289 $this->foreignNamespaces );
1292 $foreignTitle = $foreignTitleFactory->createForeignTitle( $text,
1295 $title = $this->importTitleFactory->createTitleFromForeignTitle(
1298 $commandLineMode = $this->config->get(
'CommandLineMode' );
1300 # Invalid page title? Ignore the page
1301 $this->
notice(
'import-error-invalid', $foreignTitle->getFullText() );
1303 } elseif (
$title->isExternal() ) {
1306 } elseif ( !
$title->canExist() ) {
1309 } elseif ( !$commandLineMode ) {
1312 if ( !$this->permissionManager->userCan(
'edit', $user,
$title ) ) {
1313 # Do not import if the importing wiki user cannot edit this page
1320 return [
$title, $foreignTitle ];
1327 private function getContentHandler( $model ) {
1328 return $this->contentHandlerFactory->getContentHandler( $model );
1337 private function getDefaultContentModel(
$title, $role ) {
1338 return $this->slotRoleRegistry
1339 ->getRoleHandler( $role )
1340 ->getDefaultModel(
$title );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTempDir()
Tries to get the system directory for temporary files.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the pending update queue for execution at the appropriate time.
Class to parse and build external user names.
Base class for language-specific code.
Exception representing a failure to serialize or unserialize a content object.
A class containing constants representing the names of configuration variables.
Service for creating WikiPage objects.
A parser that translates page titles on a foreign wiki into ForeignTitle objects, with no knowledge o...
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
A parser that translates page titles on a foreign wiki into ForeignTitle objects, using information a...
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
static getMain()
Get the RequestContext object associated with the main request.
static factory(array $deltas)
static newGood( $value=null)
Factory function for good results.
A class to convert page titles on a foreign wiki (ForeignTitle objects) into page titles on the local...
Represents a title within MediaWiki.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static castFromPageIdentity(?PageIdentity $pageIdentity)
Return a Title for a given PageIdentity.
getPrefixedText()
Get the prefixed title with spaces.
static registerSource(ImportSource $source)
XML file reader for the page data importer.
setImportUploads( $import)
doImport()
Primary entry point.
setPageCallback( $callback)
Sets the action to perform as each new page in the stream is reached.
setUsernamePrefix( $usernamePrefix, $assignKnownUsers)
setNoUpdates( $noupdates)
Set 'no updates' mode.
setLogItemCallback( $callback)
Sets the action to perform as each log item reached.
importUpload( $revision)
Dummy for now...
setImportTitleFactory( $factory)
Sets the factory object to use to convert ForeignTitle objects into local Title objects.
setSiteInfoCallback( $callback)
Sets the action to perform when site info is encountered.
nodeAttribute( $attr)
Retrieves the contents of the named attribute of the current element.
pageCallback( $title)
Notify the callback function when a new "<page>" is reached.
setTargetNamespace( $namespace)
Set a target namespace to override the defaults.
setPageOffset( $nthPage)
Sets 'pageOffset' value.
nodeContents()
Shouldn't something like this be built-in to XMLReader? Fetches text contents of the current element,...
importLogItem( $revision)
Default per-revision callback, performs the import.
setDebug( $debug)
Set debug mode...
__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.
notice( $msg,... $params)
importRevision( $revision)
Default per-revision callback, performs the import.
setPageOutCallback( $callback)
Sets the action to perform as each page in the stream is completed.
setTargetRootPage( $rootpage)
Set a target root page under which all pages are imported.
setNoticeCallback( $callback)
Set a callback that displays notice messages.
finishImportPage(PageIdentity $pageIdentity, $foreignTitle, $revCount, $sRevCount, $pageInfo)
Mostly for hook use.
beforeImportPage( $titleAndForeignTitle)
Default per-page callback.
disableStatisticsUpdate()
Statistics update can cause a lot of time.
setRevisionCallback( $callback)
Sets the action to perform as each page revision is reached.
setUploadCallback( $callback)
Sets the action to perform as each file upload version is reached.
Represents a revision, log entry or upload during the import process.
Interface for configuration instances.
Source interface for XML import.
Interface for objects (potentially) representing an editable wiki page.