40 use Wikimedia\AtEase\AtEase;
41 use Wikimedia\NormalizedException\NormalizedException;
54 private $sourceAdapterId;
57 private $foreignNamespaces =
null;
60 private $mLogItemCallback;
63 private $mUploadCallback;
66 private $mRevisionCallback;
69 private $mPageCallback;
72 private $mSiteInfoCallback;
75 private $mPageOutCallback;
78 private $mNoticeCallback;
84 private $mImportUploads;
87 private $mImageBasePath;
90 private $mNoUpdates =
false;
93 private $pageOffset = 0;
99 private $importTitleFactory;
105 private $countableCache = [];
108 private $disableStatisticsUpdate =
false;
111 private $externalUserNames;
114 private $contentLanguage;
117 private $namespaceInfo;
120 private $titleFactory;
123 private $wikiPageFactory;
126 private $uploadRevisionImporter;
129 private $permissionManager;
132 private $contentHandlerFactory;
135 private $slotRoleRegistry;
165 $this->reader =
new XMLReader();
166 $this->config = $config;
167 $this->hookRunner =
new HookRunner( $hookContainer );
168 $this->contentLanguage = $contentLanguage;
169 $this->namespaceInfo = $namespaceInfo;
170 $this->titleFactory = $titleFactory;
171 $this->wikiPageFactory = $wikiPageFactory;
172 $this->uploadRevisionImporter = $uploadRevisionImporter;
173 $this->permissionManager = $permissionManager;
174 $this->contentHandlerFactory = $contentHandlerFactory;
175 $this->slotRoleRegistry = $slotRoleRegistry;
177 if ( !in_array(
'uploadsource', stream_get_wrappers() ) ) {
178 stream_wrapper_register(
'uploadsource', UploadSourceAdapter::class );
192 $this->contentLanguage,
193 $this->namespaceInfo,
203 return $this->reader;
210 $this->
debug(
"FAILURE: $err" );
211 wfDebug(
"WikiImporter XML error: $err" );
218 if ( $this->mDebug ) {
226 public function warn( $data ) {
234 public function notice( $msg, ...$params ) {
235 if ( is_callable( $this->mNoticeCallback ) ) {
236 call_user_func( $this->mNoticeCallback, $msg, $params );
249 $this->mDebug = $debug;
257 $this->mNoUpdates = $noupdates;
267 $this->pageOffset = $nthPage;
277 return wfSetVar( $this->mNoticeCallback, $callback );
286 $previous = $this->mPageCallback;
287 $this->mPageCallback = $callback;
301 $previous = $this->mPageOutCallback;
302 $this->mPageOutCallback = $callback;
312 $previous = $this->mRevisionCallback;
313 $this->mRevisionCallback = $callback;
323 $previous = $this->mUploadCallback;
324 $this->mUploadCallback = $callback;
334 $previous = $this->mLogItemCallback;
335 $this->mLogItemCallback = $callback;
345 $previous = $this->mSiteInfoCallback;
346 $this->mSiteInfoCallback = $callback;
356 $this->importTitleFactory = $factory;
365 if ( $namespace ===
null ) {
369 $this->contentLanguage,
370 $this->namespaceInfo,
377 $this->namespaceInfo->exists( intval( $namespace ) )
379 $namespace = intval( $namespace );
382 $this->namespaceInfo,
400 $nsInfo = $this->namespaceInfo;
401 if ( $rootpage ===
null ) {
405 $this->contentLanguage,
410 } elseif ( $rootpage !==
'' ) {
411 $rootpage = rtrim( $rootpage,
'/' );
412 $title = Title::newFromText( $rootpage );
415 $status->fatal(
'import-rootpage-invalid' );
416 } elseif ( !$nsInfo->hasSubpages(
$title->getNamespace() ) ) {
419 : $this->contentLanguage->getNsText(
$title->getNamespace() );
420 $status->fatal(
'import-rootpage-nosubpage', $displayNSText );
440 $this->mImageBasePath = $dir;
447 $this->mImportUploads = $import;
456 $this->externalUserNames =
new ExternalUserNames( $usernamePrefix, $assignKnownUsers );
474 $title = $titleAndForeignTitle[0];
475 $page = $this->wikiPageFactory->newFromTitle(
$title );
476 $this->countableCache[
'title_' .
$title->getPrefixedText()] = $page->isCountable();
486 if ( !$revision->getContentHandler()->canBeUsedOn( $revision->getTitle() ) ) {
487 $this->
notice(
'import-error-bad-location',
488 $revision->getTitle()->getPrefixedText(),
490 $revision->getModel(),
491 $revision->getFormat()
498 return $revision->importOldRevision();
500 $this->
notice(
'import-error-unserialize',
501 $revision->getTitle()->getPrefixedText(),
503 $revision->getModel(),
504 $revision->getFormat()
517 return $revision->importLogItem();
526 $status = $this->uploadRevisionImporter->import( $revision );
527 return $status->isGood();
540 $sRevCount, $pageInfo
549 $page = $this->wikiPageFactory->newFromTitle( $pageIdentity );
551 $page->loadPageData( WikiPage::READ_LATEST );
552 $rev = $page->getRevisionRecord();
553 if ( $rev ===
null ) {
555 wfDebug( __METHOD__ .
': Skipping article count adjustment for ' . $pageIdentity .
556 ' because WikiPage::getRevisionRecord() returned null' );
559 $update = $page->newPageUpdater( $user )->prepareUpdate();
560 $countKey =
'title_' . CacheKeyHelper::getKeyForPage( $pageIdentity );
561 $countable = $update->isCountable();
562 if ( array_key_exists( $countKey, $this->countableCache ) &&
563 $countable != $this->countableCache[$countKey] ) {
565 'articles' => ( (
int)$countable - (
int)$this->countableCache[$countKey] )
571 $title = Title::castFromPageIdentity( $pageIdentity );
573 return $this->hookRunner->onAfterImportPage(
$title, $foreignTitle,
574 $revCount, $sRevCount, $pageInfo );
582 private function siteInfoCallback( $siteInfo ) {
583 if ( isset( $this->mSiteInfoCallback ) ) {
584 return call_user_func_array(
585 $this->mSiteInfoCallback,
598 if ( isset( $this->mPageCallback ) ) {
599 call_user_func( $this->mPageCallback,
$title );
611 private function pageOutCallback(
PageIdentity $pageIdentity, $foreignTitle, $revCount,
612 $sucCount, $pageInfo ) {
613 if ( isset( $this->mPageOutCallback ) ) {
614 call_user_func_array( $this->mPageOutCallback, func_get_args() );
623 private function revisionCallback( $revision ) {
624 if ( isset( $this->mRevisionCallback ) ) {
625 return call_user_func_array(
626 $this->mRevisionCallback,
639 private function logItemCallback( $revision ) {
640 if ( isset( $this->mLogItemCallback ) ) {
641 return call_user_func_array(
642 $this->mLogItemCallback,
657 return $this->reader->getAttribute( $attr ) ??
'';
668 if ( $this->reader->isEmptyElement ) {
672 while ( $this->reader->read() ) {
673 switch ( $this->reader->nodeType ) {
674 case XMLReader::TEXT:
675 case XMLReader::CDATA:
676 case XMLReader::SIGNIFICANT_WHITESPACE:
677 $buffer .= $this->reader->value;
679 case XMLReader::END_ELEMENT:
684 $this->reader->close();
695 $this->syntaxCheckXML();
701 $oldDisable = @libxml_disable_entity_loader(
true );
703 $this->reader->read();
705 if ( $this->reader->localName !=
'mediawiki' ) {
707 @libxml_disable_entity_loader( $oldDisable );
708 $error = libxml_get_last_error();
710 throw new NormalizedException(
"XML error at line {line}: {message}", [
711 'line' => $error->line,
712 'message' => $error->message,
715 throw new MWException(
"Expected <mediawiki> tag, got " .
716 $this->reader->localName );
719 $this->
debug(
"<mediawiki> tag is correct." );
721 $this->
debug(
"Starting primary dump processing loop." );
723 $keepReading = $this->reader->read();
726 while ( $keepReading ) {
727 $tag = $this->reader->localName;
728 if ( $this->pageOffset ) {
729 if ( $tag ===
'page' ) {
732 if ( $pageCount < $this->pageOffset ) {
733 $keepReading = $this->reader->next();
737 $type = $this->reader->nodeType;
739 if ( !$this->hookRunner->onImportHandleToplevelXMLTag( $this ) ) {
741 } elseif ( $tag ==
'mediawiki' &&
$type == XMLReader::END_ELEMENT ) {
743 } elseif ( $tag ==
'siteinfo' ) {
744 $this->handleSiteInfo();
745 } elseif ( $tag ==
'page' ) {
747 } elseif ( $tag ==
'logitem' ) {
748 $this->handleLogItem();
749 } elseif ( $tag !=
'#text' ) {
750 $this->
warn(
"Unhandled top-level XML tag $tag" );
756 $keepReading = $this->reader->next();
758 $this->
debug(
"Skip" );
760 $keepReading = $this->reader->read();
765 @libxml_disable_entity_loader( $oldDisable );
766 $this->reader->close();
772 private function handleSiteInfo() {
773 $this->
debug(
"Enter site info handler." );
777 $normalFields = [
'sitename',
'base',
'generator',
'case' ];
779 while ( $this->reader->read() ) {
780 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
781 $this->reader->localName ==
'siteinfo' ) {
785 $tag = $this->reader->localName;
787 if ( $tag ==
'namespace' ) {
790 } elseif ( in_array( $tag, $normalFields ) ) {
795 $siteInfo[
'_namespaces'] = $this->foreignNamespaces;
796 $this->siteInfoCallback( $siteInfo );
799 private function handleLogItem() {
800 $this->
debug(
"Enter log item handler." );
804 $normalFields = [
'id',
'comment',
'type',
'action',
'timestamp',
805 'logtitle',
'params' ];
807 while ( $this->reader->read() ) {
808 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
809 $this->reader->localName ==
'logitem' ) {
813 $tag = $this->reader->localName;
815 if ( !$this->hookRunner->onImportHandleLogItemXMLTag( $this, $logInfo ) ) {
817 } elseif ( in_array( $tag, $normalFields ) ) {
819 } elseif ( $tag ==
'contributor' ) {
820 $logInfo[
'contributor'] = $this->handleContributor();
821 } elseif ( $tag !=
'#text' ) {
822 $this->
warn(
"Unhandled log-item XML tag $tag" );
826 $this->processLogItem( $logInfo );
833 private function processLogItem( $logInfo ) {
836 if ( isset( $logInfo[
'id'] ) ) {
837 $revision->setID( $logInfo[
'id'] );
839 $revision->setType( $logInfo[
'type'] );
840 $revision->setAction( $logInfo[
'action'] );
841 if ( isset( $logInfo[
'timestamp'] ) ) {
842 $revision->setTimestamp( $logInfo[
'timestamp'] );
844 if ( isset( $logInfo[
'params'] ) ) {
845 $revision->setParams( $logInfo[
'params'] );
847 if ( isset( $logInfo[
'logtitle'] ) ) {
850 $revision->setTitle( Title::newFromText( $logInfo[
'logtitle'] ) );
853 $revision->setNoUpdates( $this->mNoUpdates );
855 if ( isset( $logInfo[
'comment'] ) ) {
856 $revision->setComment( $logInfo[
'comment'] );
859 if ( isset( $logInfo[
'contributor'][
'username'] ) ) {
860 $revision->setUsername(
861 $this->externalUserNames->applyPrefix( $logInfo[
'contributor'][
'username'] )
863 } elseif ( isset( $logInfo[
'contributor'][
'ip'] ) ) {
864 $revision->setUserIP( $logInfo[
'contributor'][
'ip'] );
866 $revision->setUsername( $this->externalUserNames->addPrefix(
'Unknown user' ) );
869 return $this->logItemCallback( $revision );
872 private function handlePage() {
874 $this->
debug(
"Enter page handler." );
875 $pageInfo = [
'revisionCount' => 0,
'successfulRevisionCount' => 0 ];
878 $normalFields = [
'title',
'ns',
'id',
'redirect',
'restrictions' ];
883 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
884 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
885 $this->reader->localName ==
'page' ) {
891 $tag = $this->reader->localName;
896 } elseif ( !$this->hookRunner->onImportHandlePageXMLTag( $this, $pageInfo ) ) {
898 } elseif ( in_array( $tag, $normalFields ) ) {
906 if ( $tag ==
'redirect' ) {
911 } elseif ( $tag ==
'revision' || $tag ==
'upload' ) {
913 $title = $this->processTitle( $pageInfo[
'title'],
914 $pageInfo[
'ns'] ??
null );
917 if ( is_array(
$title ) ) {
919 [ $pageInfo[
'_title'], $foreignTitle ] =
$title;
927 if ( $tag ==
'revision' ) {
928 $this->handleRevision( $pageInfo );
930 $this->handleUpload( $pageInfo );
933 } elseif ( $tag !=
'#text' ) {
934 $this->
warn(
"Unhandled page XML tag $tag" );
944 if ( array_key_exists(
'_title', $pageInfo ) ) {
946 $title = $pageInfo[
'_title'];
947 $this->pageOutCallback(
951 $pageInfo[
'revisionCount'],
952 $pageInfo[
'successfulRevisionCount'],
961 private function handleRevision( &$pageInfo ) {
962 $this->
debug(
"Enter revision handler" );
965 $normalFields = [
'id',
'parentid',
'timestamp',
'comment',
'minor',
'origin',
966 'model',
'format',
'text',
'sha1' ];
970 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
971 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
972 $this->reader->localName ==
'revision' ) {
976 $tag = $this->reader->localName;
978 if ( !$this->hookRunner->onImportHandleRevisionXMLTag(
979 $this, $pageInfo, $revisionInfo )
982 } elseif ( in_array( $tag, $normalFields ) ) {
984 } elseif ( $tag ==
'content' ) {
986 $revisionInfo[$tag][] = $this->handleContent();
987 } elseif ( $tag ==
'contributor' ) {
988 $revisionInfo[
'contributor'] = $this->handleContributor();
989 } elseif ( $tag !=
'#text' ) {
990 $this->
warn(
"Unhandled revision XML tag $tag" );
995 $pageInfo[
'revisionCount']++;
996 if ( $this->processRevision( $pageInfo, $revisionInfo ) ) {
997 $pageInfo[
'successfulRevisionCount']++;
1001 private function handleContent() {
1002 $this->
debug(
"Enter content handler" );
1005 $normalFields = [
'role',
'origin',
'model',
'format',
'text' ];
1009 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
1010 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
1011 $this->reader->localName ==
'content' ) {
1015 $tag = $this->reader->localName;
1017 if ( !$this->hookRunner->onImportHandleContentXMLTag(
1018 $this, $contentInfo )
1021 } elseif ( in_array( $tag, $normalFields ) ) {
1023 } elseif ( $tag !=
'#text' ) {
1024 $this->
warn(
"Unhandled content XML tag $tag" );
1029 return $contentInfo;
1040 private function makeContent(
Title $title, $revisionId, $contentInfo ) {
1041 $maxArticleSize = MediaWikiServices::getInstance()->getMainConfig()->get(
1042 MainConfigNames::MaxArticleSize );
1044 if ( !isset( $contentInfo[
'text'] ) ) {
1045 throw new MWException(
'Missing text field in import.' );
1052 if ( ( !isset( $contentInfo[
'model'] ) ||
1053 in_array( $contentInfo[
'model'], [
1061 strlen( $contentInfo[
'text'] ) > $maxArticleSize * 1024
1065 "the revision with ID $revisionId" :
1067 ) .
" exceeds the maximum allowable size ({$maxArticleSize} KiB)" );
1070 $role = $contentInfo[
'role'] ?? SlotRecord::MAIN;
1071 $model = $contentInfo[
'model'] ?? $this->getDefaultContentModel(
$title, $role );
1072 $handler = $this->getContentHandler( $model );
1074 $text = $handler->importTransform( $contentInfo[
'text'] );
1076 return $handler->unserializeContent( $text );
1085 private function processRevision( $pageInfo, $revisionInfo ) {
1088 $revId = $revisionInfo[
'id'] ?? 0;
1090 $revision->setID( $revisionInfo[
'id'] );
1093 $title = $pageInfo[
'_title'];
1094 $revision->setTitle(
$title );
1097 $revision->setContent( SlotRecord::MAIN,
$content );
1099 foreach ( $revisionInfo[
'content'] ?? [] as $slotInfo ) {
1100 if ( !isset( $slotInfo[
'role'] ) ) {
1101 throw new MWException(
"Missing role for imported slot." );
1105 $revision->setContent( $slotInfo[
'role'],
$content );
1107 $revision->setTimestamp( $revisionInfo[
'timestamp'] ??
wfTimestampNow() );
1109 if ( isset( $revisionInfo[
'comment'] ) ) {
1110 $revision->setComment( $revisionInfo[
'comment'] );
1113 if ( isset( $revisionInfo[
'minor'] ) ) {
1114 $revision->setMinor(
true );
1116 if ( isset( $revisionInfo[
'contributor'][
'username'] ) ) {
1117 $revision->setUsername(
1118 $this->externalUserNames->applyPrefix( $revisionInfo[
'contributor'][
'username'] )
1120 } elseif ( isset( $revisionInfo[
'contributor'][
'ip'] ) ) {
1121 $revision->setUserIP( $revisionInfo[
'contributor'][
'ip'] );
1123 $revision->setUsername( $this->externalUserNames->addPrefix(
'Unknown user' ) );
1125 if ( isset( $revisionInfo[
'sha1'] ) ) {
1126 $revision->setSha1Base36( $revisionInfo[
'sha1'] );
1128 $revision->setNoUpdates( $this->mNoUpdates );
1130 return $this->revisionCallback( $revision );
1137 private function handleUpload( &$pageInfo ) {
1138 $this->
debug(
"Enter upload handler" );
1141 $normalFields = [
'timestamp',
'comment',
'filename',
'text',
1142 'src',
'size',
'sha1base36',
'archivename',
'rel' ];
1146 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
1147 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
1148 $this->reader->localName ==
'upload' ) {
1152 $tag = $this->reader->localName;
1154 if ( !$this->hookRunner->onImportHandleUploadXMLTag( $this, $pageInfo ) ) {
1156 } elseif ( in_array( $tag, $normalFields ) ) {
1158 } elseif ( $tag ==
'contributor' ) {
1159 $uploadInfo[
'contributor'] = $this->handleContributor();
1160 } elseif ( $tag ==
'contents' ) {
1162 $encoding = $this->reader->getAttribute(
'encoding' );
1163 if ( $encoding ===
'base64' ) {
1164 $uploadInfo[
'fileSrc'] = $this->dumpTemp( base64_decode( $contents ) );
1165 $uploadInfo[
'isTempSrc'] =
true;
1167 } elseif ( $tag !=
'#text' ) {
1168 $this->
warn(
"Unhandled upload XML tag $tag" );
1173 if ( $this->mImageBasePath && isset( $uploadInfo[
'rel'] ) ) {
1174 $path =
"{$this->mImageBasePath}/{$uploadInfo['rel']}";
1175 if ( file_exists(
$path ) ) {
1176 $uploadInfo[
'fileSrc'] =
$path;
1177 $uploadInfo[
'isTempSrc'] =
false;
1181 if ( $this->mImportUploads ) {
1182 return $this->processUpload( $pageInfo, $uploadInfo );
1190 private function dumpTemp( $contents ) {
1191 $filename = tempnam(
wfTempDir(),
'importupload' );
1192 file_put_contents( $filename, $contents );
1201 private function processUpload( $pageInfo, $uploadInfo ) {
1203 $revId = $pageInfo[
'id'];
1204 $title = $pageInfo[
'_title'];
1206 $uploadInfo[
'text'] = $uploadInfo[
'text'] ??
'';
1209 $revision->setTitle(
$title );
1210 $revision->setID( $revId );
1211 $revision->setTimestamp( $uploadInfo[
'timestamp'] );
1212 $revision->setContent( SlotRecord::MAIN,
$content );
1213 $revision->setFilename( $uploadInfo[
'filename'] );
1214 if ( isset( $uploadInfo[
'archivename'] ) ) {
1215 $revision->setArchiveName( $uploadInfo[
'archivename'] );
1217 $revision->setSrc( $uploadInfo[
'src'] );
1218 if ( isset( $uploadInfo[
'fileSrc'] ) ) {
1219 $revision->setFileSrc( $uploadInfo[
'fileSrc'],
1220 !empty( $uploadInfo[
'isTempSrc'] )
1223 if ( isset( $uploadInfo[
'sha1base36'] ) ) {
1224 $revision->setSha1Base36( $uploadInfo[
'sha1base36'] );
1226 $revision->setSize( intval( $uploadInfo[
'size'] ) );
1227 $revision->setComment( $uploadInfo[
'comment'] );
1229 if ( isset( $uploadInfo[
'contributor'][
'username'] ) ) {
1230 $revision->setUsername(
1231 $this->externalUserNames->applyPrefix( $uploadInfo[
'contributor'][
'username'] )
1233 } elseif ( isset( $uploadInfo[
'contributor'][
'ip'] ) ) {
1234 $revision->setUserIP( $uploadInfo[
'contributor'][
'ip'] );
1236 $revision->setNoUpdates( $this->mNoUpdates );
1238 return call_user_func( $this->mUploadCallback, $revision );
1244 private function handleContributor() {
1245 $this->
debug(
"Enter contributor handler." );
1247 if ( $this->reader->isEmptyElement ) {
1251 $fields = [
'id',
'ip',
'username' ];
1254 while ( $this->reader->read() ) {
1255 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
1256 $this->reader->localName ==
'contributor' ) {
1260 $tag = $this->reader->localName;
1262 if ( in_array( $tag, $fields ) ) {
1275 private function processTitle( $text, $ns =
null ) {
1276 if ( $this->foreignNamespaces ===
null ) {
1278 $this->contentLanguage
1282 $this->foreignNamespaces );
1285 $foreignTitle = $foreignTitleFactory->createForeignTitle( $text,
1288 $title = $this->importTitleFactory->createTitleFromForeignTitle(
1291 $commandLineMode = $this->config->get(
'CommandLineMode' );
1293 # Invalid page title? Ignore the page
1294 $this->
notice(
'import-error-invalid', $foreignTitle->getFullText() );
1296 } elseif (
$title->isExternal() ) {
1299 } elseif ( !
$title->canExist() ) {
1302 } elseif ( !$commandLineMode ) {
1305 if ( !$this->permissionManager->userCan(
'edit', $user,
$title ) ) {
1306 # Do not import if the importing wiki user cannot edit this page
1313 return [
$title, $foreignTitle ];
1320 private function getContentHandler( $model ) {
1321 return $this->contentHandlerFactory->getContentHandler( $model );
1330 private function getDefaultContentModel(
$title, $role ) {
1331 return $this->slotRoleRegistry
1332 ->getRoleHandler( $role )
1333 ->getDefaultModel(
$title );
1339 private function openReader() {
1343 $oldDisable = @libxml_disable_entity_loader(
false );
1344 if ( defined(
'LIBXML_PARSEHUGE' ) ) {
1345 $status = $this->reader->open(
'uploadsource://' . $this->sourceAdapterId,
null, LIBXML_PARSEHUGE );
1347 $status = $this->reader->open(
'uploadsource://' . $this->sourceAdapterId );
1350 $error = libxml_get_last_error();
1352 @libxml_disable_entity_loader( $oldDisable );
1354 'Encountered an internal error while initializing WikiImporter object: ' . $error->message
1358 @libxml_disable_entity_loader( $oldDisable );
1364 private function syntaxCheckXML() {
1368 AtEase::suppressWarnings();
1369 $oldDisable = libxml_disable_entity_loader(
false );
1371 while ( $this->reader->read() );
1372 $error = libxml_get_last_error();
1374 $errorMessage =
'XML error at line ' . $error->line .
': ' . $error->message;
1375 wfDebug( __METHOD__ .
': Invalid xml found - ' . $errorMessage );
1379 libxml_disable_entity_loader( $oldDisable );
1380 AtEase::restoreWarnings();
1381 $this->reader->close();
1386 $this->openReader();
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...
static seekSource(string $id, int $offset)
static isSeekableSource(string $id)
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.