69 private $sourceAdapterId;
72 private $foreignNamespaces =
null;
75 private $mLogItemCallback;
78 private $mUploadCallback;
81 private $mRevisionCallback;
84 private $mPageCallback;
87 private $mSiteInfoCallback;
90 private $mPageOutCallback;
93 private $mNoticeCallback;
99 private $mImportUploads;
102 private $mImageBasePath;
105 private $mNoUpdates =
false;
108 private $pageOffset = 0;
114 private $countableCache = [];
117 private $disableStatisticsUpdate =
false;
153 $this->performer = $performer;
154 $this->config = $config;
155 $this->hookRunner =
new HookRunner( $hookContainer );
156 $this->contentLanguage = $contentLanguage;
157 $this->namespaceInfo = $namespaceInfo;
158 $this->titleFactory = $titleFactory;
159 $this->wikiPageFactory = $wikiPageFactory;
160 $this->uploadRevisionImporter = $uploadRevisionImporter;
161 $this->contentHandlerFactory = $contentHandlerFactory;
162 $this->slotRoleRegistry = $slotRoleRegistry;
164 if ( !in_array(
'uploadsource', stream_get_wrappers() ) ) {
165 stream_wrapper_register(
'uploadsource', UploadSourceAdapter::class );
179 $this->contentLanguage,
180 $this->namespaceInfo,
190 return $this->reader;
197 $this->
debug(
"FAILURE: $err" );
198 wfDebug(
"WikiImporter XML error: $err" );
205 if ( $this->mDebug ) {
213 public function warn( $data ) {
222 if ( is_callable( $this->mNoticeCallback ) ) {
223 call_user_func( $this->mNoticeCallback, $msg,
$params );
236 $this->mDebug = $debug;
244 $this->mNoUpdates = $noupdates;
254 $this->pageOffset = $nthPage;
264 return wfSetVar( $this->mNoticeCallback, $callback );
273 $previous = $this->mPageCallback;
274 $this->mPageCallback = $callback;
288 $previous = $this->mPageOutCallback;
289 $this->mPageOutCallback = $callback;
299 $previous = $this->mRevisionCallback;
300 $this->mRevisionCallback = $callback;
310 $previous = $this->mUploadCallback;
311 $this->mUploadCallback = $callback;
321 $previous = $this->mLogItemCallback;
322 $this->mLogItemCallback = $callback;
332 $previous = $this->mSiteInfoCallback;
333 $this->mSiteInfoCallback = $callback;
343 $this->importTitleFactory = $factory;
352 if ( $namespace ===
null ) {
356 $this->contentLanguage,
357 $this->namespaceInfo,
364 $this->namespaceInfo->exists( intval( $namespace ) )
366 $namespace = intval( $namespace );
369 $this->namespaceInfo,
386 $status = Status::newGood();
387 $nsInfo = $this->namespaceInfo;
388 if ( $rootpage ===
null ) {
392 $this->contentLanguage,
397 } elseif ( $rootpage !==
'' ) {
398 $rootpage = rtrim( $rootpage,
'/' );
399 $title = Title::newFromText( $rootpage );
401 if ( !$title || $title->isExternal() ) {
402 $status->fatal(
'import-rootpage-invalid' );
403 } elseif ( !$nsInfo->hasSubpages( $title->getNamespace() ) ) {
404 $displayNSText = $title->getNamespace() ===
NS_MAIN
406 : $this->contentLanguage->getNsText( $title->getNamespace() );
407 $status->fatal(
'import-rootpage-nosubpage', $displayNSText );
427 $this->mImageBasePath = $dir;
434 $this->mImportUploads = $import;
443 $this->externalUserNames =
new ExternalUserNames( $usernamePrefix, $assignKnownUsers );
461 $title = $titleAndForeignTitle[0];
462 $page = $this->wikiPageFactory->newFromTitle( $title );
463 $this->countableCache[
'title_' . $title->getPrefixedText()] = $page->isCountable();
473 if ( !$revision->getContentHandler()->canBeUsedOn( $revision->getTitle() ) ) {
474 $this->
notice(
'import-error-bad-location',
475 $revision->getTitle()->getPrefixedText(),
477 $revision->getModel(),
478 $revision->getFormat()
485 return $revision->importOldRevision();
487 $this->
notice(
'import-error-unserialize',
488 $revision->getTitle()->getPrefixedText(),
490 $revision->getModel(),
491 $revision->getFormat()
504 return $revision->importLogItem();
513 $status = $this->uploadRevisionImporter->import( $revision );
514 return $status->isGood();
527 $sRevCount, $pageInfo
536 $page = $this->wikiPageFactory->newFromTitle( $pageIdentity );
538 $page->loadPageData( IDBAccessObject::READ_LATEST );
539 $rev = $page->getRevisionRecord();
540 if ( $rev ===
null ) {
542 wfDebug( __METHOD__ .
': Skipping article count adjustment for ' . $pageIdentity .
543 ' because WikiPage::getRevisionRecord() returned null' );
545 $update = $page->newPageUpdater( $this->performer )->prepareUpdate();
546 $countKey =
'title_' . CacheKeyHelper::getKeyForPage( $pageIdentity );
547 $countable = $update->isCountable();
548 if ( array_key_exists( $countKey, $this->countableCache ) &&
549 $countable != $this->countableCache[$countKey] ) {
550 DeferredUpdates::addUpdate( SiteStatsUpdate::factory( [
551 'articles' => ( (
int)$countable - (
int)$this->countableCache[$countKey] )
557 $title = Title::newFromPageIdentity( $pageIdentity );
558 return $this->hookRunner->onAfterImportPage( $title, $foreignTitle,
559 $revCount, $sRevCount, $pageInfo );
567 private function siteInfoCallback( $siteInfo ) {
568 if ( isset( $this->mSiteInfoCallback ) ) {
569 return call_user_func_array(
570 $this->mSiteInfoCallback,
583 if ( isset( $this->mPageCallback ) ) {
584 call_user_func( $this->mPageCallback, $title );
596 private function pageOutCallback(
PageIdentity $pageIdentity, $foreignTitle, $revCount,
597 $sucCount, $pageInfo ) {
598 if ( isset( $this->mPageOutCallback ) ) {
599 call_user_func_array( $this->mPageOutCallback, func_get_args() );
608 private function revisionCallback( $revision ) {
609 if ( isset( $this->mRevisionCallback ) ) {
610 return call_user_func_array(
611 $this->mRevisionCallback,
624 private function logItemCallback( $revision ) {
625 if ( isset( $this->mLogItemCallback ) ) {
626 return call_user_func_array(
627 $this->mLogItemCallback,
642 return $this->reader->getAttribute( $attr ) ??
'';
653 if ( $this->reader->isEmptyElement ) {
657 while ( $this->reader->read() ) {
658 switch ( $this->reader->nodeType ) {
659 case XMLReader::TEXT:
660 case XMLReader::CDATA:
661 case XMLReader::SIGNIFICANT_WHITESPACE:
662 $buffer .= $this->reader->value;
664 case XMLReader::END_ELEMENT:
669 $this->reader->close();
679 $this->syntaxCheckXML();
685 $oldDisable = @libxml_disable_entity_loader(
true );
687 $this->reader->read();
689 if ( $this->reader->localName !=
'mediawiki' ) {
691 @libxml_disable_entity_loader( $oldDisable );
692 $error = libxml_get_last_error();
694 throw new NormalizedException(
"XML error at line {line}: {message}", [
695 'line' => $error->line,
696 'message' => $error->message,
699 throw new UnexpectedValueException(
700 "Expected '<mediawiki>' tag, got '<{$this->reader->localName}>' tag."
704 $this->
debug(
"<mediawiki> tag is correct." );
706 $this->
debug(
"Starting primary dump processing loop." );
708 $keepReading = $this->reader->read();
711 while ( $keepReading ) {
712 $tag = $this->reader->localName;
713 if ( $this->pageOffset ) {
714 if ( $tag ===
'page' ) {
717 if ( $pageCount < $this->pageOffset ) {
718 $keepReading = $this->reader->next();
722 $type = $this->reader->nodeType;
724 if ( !$this->hookRunner->onImportHandleToplevelXMLTag( $this ) ) {
726 } elseif ( $tag ==
'mediawiki' && $type == XMLReader::END_ELEMENT ) {
728 } elseif ( $tag ==
'siteinfo' ) {
729 $this->handleSiteInfo();
730 } elseif ( $tag ==
'page' ) {
732 } elseif ( $tag ==
'logitem' ) {
733 $this->handleLogItem();
734 } elseif ( $tag !=
'#text' ) {
735 $this->
warn(
"Unhandled top-level XML tag $tag" );
741 $keepReading = $this->reader->next();
743 $this->
debug(
"Skip" );
745 $keepReading = $this->reader->read();
750 @libxml_disable_entity_loader( $oldDisable );
751 $this->reader->close();
757 private function handleSiteInfo() {
758 $this->debug(
"Enter site info handler." );
762 $normalFields = [
'sitename',
'base',
'generator',
'case' ];
764 while ( $this->reader->read() ) {
765 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
766 $this->reader->localName ==
'siteinfo' ) {
770 $tag = $this->reader->localName;
772 if ( $tag ==
'namespace' ) {
775 } elseif ( in_array( $tag, $normalFields ) ) {
780 $siteInfo[
'_namespaces'] = $this->foreignNamespaces;
781 $this->siteInfoCallback( $siteInfo );
784 private function handleLogItem() {
785 $this->
debug(
"Enter log item handler." );
789 $normalFields = [
'id',
'comment',
'type',
'action',
'timestamp',
790 'logtitle',
'params' ];
792 while ( $this->reader->read() ) {
793 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
794 $this->reader->localName ==
'logitem' ) {
798 $tag = $this->reader->localName;
800 if ( !$this->hookRunner->onImportHandleLogItemXMLTag( $this, $logInfo ) ) {
802 } elseif ( in_array( $tag, $normalFields ) ) {
804 } elseif ( $tag ==
'contributor' ) {
805 $logInfo[
'contributor'] = $this->handleContributor();
806 } elseif ( $tag !=
'#text' ) {
807 $this->
warn(
"Unhandled log-item XML tag $tag" );
811 $this->processLogItem( $logInfo );
818 private function processLogItem( $logInfo ) {
821 if ( isset( $logInfo[
'id'] ) ) {
822 $revision->setID( $logInfo[
'id'] );
824 $revision->setType( $logInfo[
'type'] );
825 $revision->setAction( $logInfo[
'action'] );
826 if ( isset( $logInfo[
'timestamp'] ) ) {
827 $revision->setTimestamp( $logInfo[
'timestamp'] );
829 if ( isset( $logInfo[
'params'] ) ) {
830 $revision->setParams( $logInfo[
'params'] );
832 if ( isset( $logInfo[
'logtitle'] ) ) {
835 $revision->setTitle( Title::newFromText( $logInfo[
'logtitle'] ) );
838 $revision->setNoUpdates( $this->mNoUpdates );
840 if ( isset( $logInfo[
'comment'] ) ) {
841 $revision->setComment( $logInfo[
'comment'] );
844 if ( isset( $logInfo[
'contributor'][
'username'] ) ) {
845 $revision->setUsername(
846 $this->externalUserNames->applyPrefix( $logInfo[
'contributor'][
'username'] )
848 } elseif ( isset( $logInfo[
'contributor'][
'ip'] ) ) {
849 $revision->setUserIP( $logInfo[
'contributor'][
'ip'] );
851 $revision->setUsername( $this->externalUserNames->addPrefix(
'Unknown user' ) );
854 return $this->logItemCallback( $revision );
857 private function handlePage() {
859 $this->
debug(
"Enter page handler." );
860 $pageInfo = [
'revisionCount' => 0,
'successfulRevisionCount' => 0 ];
863 $normalFields = [
'title',
'ns',
'id',
'redirect',
'restrictions' ];
868 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
869 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
870 $this->reader->localName ==
'page' ) {
876 $tag = $this->reader->localName;
881 } elseif ( !$this->hookRunner->onImportHandlePageXMLTag( $this, $pageInfo ) ) {
883 } elseif ( in_array( $tag, $normalFields ) ) {
891 if ( $tag ==
'redirect' ) {
896 } elseif ( $tag ==
'revision' || $tag ==
'upload' ) {
897 if ( !isset( $title ) ) {
898 $title = $this->processTitle( $pageInfo[
'title'],
899 $pageInfo[
'ns'] ??
null );
902 if ( is_array( $title ) ) {
904 [ $pageInfo[
'_title'], $foreignTitle ] = $title;
912 if ( $tag ==
'revision' ) {
913 $this->handleRevision( $pageInfo );
915 $this->handleUpload( $pageInfo );
918 } elseif ( $tag !=
'#text' ) {
919 $this->
warn(
"Unhandled page XML tag $tag" );
929 if ( array_key_exists(
'_title', $pageInfo ) ) {
931 $title = $pageInfo[
'_title'];
932 $this->pageOutCallback(
936 $pageInfo[
'revisionCount'],
937 $pageInfo[
'successfulRevisionCount'],
946 private function handleRevision( &$pageInfo ) {
947 $this->
debug(
"Enter revision handler" );
950 $normalFields = [
'id',
'parentid',
'timestamp',
'comment',
'minor',
'origin',
951 'model',
'format',
'text',
'sha1' ];
955 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
956 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
957 $this->reader->localName ==
'revision' ) {
961 $tag = $this->reader->localName;
963 if ( !$this->hookRunner->onImportHandleRevisionXMLTag(
964 $this, $pageInfo, $revisionInfo )
967 } elseif ( in_array( $tag, $normalFields ) ) {
969 } elseif ( $tag ==
'content' ) {
971 $revisionInfo[$tag][] = $this->handleContent();
972 } elseif ( $tag ==
'contributor' ) {
973 $revisionInfo[
'contributor'] = $this->handleContributor();
974 } elseif ( $tag !=
'#text' ) {
975 $this->
warn(
"Unhandled revision XML tag $tag" );
980 $pageInfo[
'revisionCount']++;
981 if ( $this->processRevision( $pageInfo, $revisionInfo ) ) {
982 $pageInfo[
'successfulRevisionCount']++;
986 private function handleContent() {
987 $this->
debug(
"Enter content handler" );
990 $normalFields = [
'role',
'origin',
'model',
'format',
'text' ];
994 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
995 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
996 $this->reader->localName ==
'content' ) {
1000 $tag = $this->reader->localName;
1002 if ( !$this->hookRunner->onImportHandleContentXMLTag(
1003 $this, $contentInfo )
1006 } elseif ( in_array( $tag, $normalFields ) ) {
1008 } elseif ( $tag !=
'#text' ) {
1009 $this->
warn(
"Unhandled content XML tag $tag" );
1014 return $contentInfo;
1024 private function makeContent(
PageIdentity $page, $revisionId, $contentInfo ) {
1025 $maxArticleSize = $this->config->get( MainConfigNames::MaxArticleSize );
1027 if ( !isset( $contentInfo[
'text'] ) ) {
1028 throw new InvalidArgumentException(
'Missing text field in import.' );
1035 if ( ( !isset( $contentInfo[
'model'] ) ||
1036 in_array( $contentInfo[
'model'], [
1044 strlen( $contentInfo[
'text'] ) > $maxArticleSize * 1024
1046 throw new RuntimeException(
'The text of ' .
1048 "the revision with ID $revisionId" :
1050 ) .
" exceeds the maximum allowable size ({$maxArticleSize} KiB)" );
1053 $role = $contentInfo[
'role'] ?? SlotRecord::MAIN;
1054 $model = $contentInfo[
'model'] ?? $this->slotRoleRegistry
1055 ->getRoleHandler( $role )
1056 ->getDefaultModel( $page );
1057 $handler = $this->contentHandlerFactory->getContentHandler( $model );
1059 $text = $handler->importTransform( $contentInfo[
'text'] );
1061 return $handler->unserializeContent( $text );
1069 private function processRevision( $pageInfo, $revisionInfo ) {
1072 $revId = $revisionInfo[
'id'] ?? 0;
1074 $revision->setID( $revisionInfo[
'id'] );
1077 $title = $pageInfo[
'_title'];
1078 $revision->setTitle( $title );
1080 $content = $this->makeContent( $title, $revId, $revisionInfo );
1081 $revision->setContent( SlotRecord::MAIN, $content );
1083 foreach ( $revisionInfo[
'content'] ?? [] as $slotInfo ) {
1084 if ( !isset( $slotInfo[
'role'] ) ) {
1085 throw new RuntimeException(
"Missing role for imported slot." );
1088 $content = $this->makeContent( $title, $revId, $slotInfo );
1089 $revision->setContent( $slotInfo[
'role'], $content );
1091 $revision->setTimestamp( $revisionInfo[
'timestamp'] ??
wfTimestampNow() );
1093 if ( isset( $revisionInfo[
'comment'] ) ) {
1094 $revision->setComment( $revisionInfo[
'comment'] );
1097 if ( isset( $revisionInfo[
'minor'] ) ) {
1098 $revision->setMinor(
true );
1100 if ( isset( $revisionInfo[
'contributor'][
'username'] ) ) {
1101 $revision->setUsername(
1102 $this->externalUserNames->applyPrefix( $revisionInfo[
'contributor'][
'username'] )
1104 } elseif ( isset( $revisionInfo[
'contributor'][
'ip'] ) ) {
1105 $revision->setUserIP( $revisionInfo[
'contributor'][
'ip'] );
1107 $revision->setUsername( $this->externalUserNames->addPrefix(
'Unknown user' ) );
1109 if ( isset( $revisionInfo[
'sha1'] ) ) {
1110 $revision->setSha1Base36( $revisionInfo[
'sha1'] );
1112 $revision->setNoUpdates( $this->mNoUpdates );
1114 return $this->revisionCallback( $revision );
1121 private function handleUpload( &$pageInfo ) {
1122 $this->
debug(
"Enter upload handler" );
1125 $normalFields = [
'timestamp',
'comment',
'filename',
'text',
1126 'src',
'size',
'sha1base36',
'archivename',
'rel' ];
1130 while ( $skip ? $this->reader->next() : $this->reader->read() ) {
1131 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
1132 $this->reader->localName ==
'upload' ) {
1136 $tag = $this->reader->localName;
1138 if ( !$this->hookRunner->onImportHandleUploadXMLTag( $this, $pageInfo ) ) {
1140 } elseif ( in_array( $tag, $normalFields ) ) {
1142 } elseif ( $tag ==
'contributor' ) {
1143 $uploadInfo[
'contributor'] = $this->handleContributor();
1144 } elseif ( $tag ==
'contents' ) {
1146 $encoding = $this->reader->getAttribute(
'encoding' );
1147 if ( $encoding ===
'base64' ) {
1148 $uploadInfo[
'fileSrc'] = $this->dumpTemp( base64_decode( $contents ) );
1149 $uploadInfo[
'isTempSrc'] =
true;
1151 } elseif ( $tag !=
'#text' ) {
1152 $this->
warn(
"Unhandled upload XML tag $tag" );
1157 if ( $this->mImageBasePath && isset( $uploadInfo[
'rel'] ) ) {
1158 $path =
"{$this->mImageBasePath}/{$uploadInfo['rel']}";
1159 if ( file_exists(
$path ) ) {
1160 $uploadInfo[
'fileSrc'] =
$path;
1161 $uploadInfo[
'isTempSrc'] =
false;
1165 if ( $this->mImportUploads ) {
1166 return $this->processUpload( $pageInfo, $uploadInfo );
1174 private function dumpTemp( $contents ) {
1175 $filename = tempnam(
wfTempDir(),
'importupload' );
1176 file_put_contents( $filename, $contents );
1185 private function processUpload( $pageInfo, $uploadInfo ) {
1187 $revId = $pageInfo[
'id'];
1188 $title = $pageInfo[
'_title'];
1190 $uploadInfo[
'text'] ??=
'';
1191 $content = $this->makeContent( $title, $revId, $uploadInfo );
1193 $revision->setTitle( $title );
1194 $revision->setID( $revId );
1195 $revision->setTimestamp( $uploadInfo[
'timestamp'] );
1196 $revision->setContent( SlotRecord::MAIN, $content );
1197 $revision->setFilename( $uploadInfo[
'filename'] );
1198 if ( isset( $uploadInfo[
'archivename'] ) ) {
1199 $revision->setArchiveName( $uploadInfo[
'archivename'] );
1201 $revision->setSrc( $uploadInfo[
'src'] );
1202 if ( isset( $uploadInfo[
'fileSrc'] ) ) {
1203 $revision->setFileSrc( $uploadInfo[
'fileSrc'],
1204 !empty( $uploadInfo[
'isTempSrc'] )
1207 if ( isset( $uploadInfo[
'sha1base36'] ) ) {
1208 $revision->setSha1Base36( $uploadInfo[
'sha1base36'] );
1210 $revision->setSize( intval( $uploadInfo[
'size'] ) );
1211 $revision->setComment( $uploadInfo[
'comment'] );
1213 if ( isset( $uploadInfo[
'contributor'][
'username'] ) ) {
1214 $revision->setUsername(
1215 $this->externalUserNames->applyPrefix( $uploadInfo[
'contributor'][
'username'] )
1217 } elseif ( isset( $uploadInfo[
'contributor'][
'ip'] ) ) {
1218 $revision->setUserIP( $uploadInfo[
'contributor'][
'ip'] );
1220 $revision->setNoUpdates( $this->mNoUpdates );
1222 return call_user_func( $this->mUploadCallback, $revision );
1228 private function handleContributor() {
1229 $this->
debug(
"Enter contributor handler." );
1231 if ( $this->reader->isEmptyElement ) {
1235 $fields = [
'id',
'ip',
'username' ];
1238 while ( $this->reader->read() ) {
1239 if ( $this->reader->nodeType == XMLReader::END_ELEMENT &&
1240 $this->reader->localName ==
'contributor' ) {
1244 $tag = $this->reader->localName;
1246 if ( in_array( $tag, $fields ) ) {
1259 private function processTitle( $text, $ns =
null ) {
1260 if ( $this->foreignNamespaces ===
null ) {
1262 $this->contentLanguage
1266 $this->foreignNamespaces );
1269 $foreignTitle = $foreignTitleFactory->createForeignTitle( $text,
1272 $title = $this->importTitleFactory->createTitleFromForeignTitle(
1275 if ( $title ===
null ) {
1276 # Invalid page title? Ignore the page
1277 $this->
notice(
'import-error-invalid', $foreignTitle->getFullText() );
1279 } elseif ( $title->isExternal() ) {
1280 $this->
notice(
'import-error-interwiki', $title->getPrefixedText() );
1282 } elseif ( !$title->canExist() ) {
1283 $this->
notice(
'import-error-special', $title->getPrefixedText() );
1285 } elseif ( !$this->performer->definitelyCan(
'edit', $title ) ) {
1286 # Do not import if the importing wiki user cannot edit this page
1287 $this->
notice(
'import-error-edit', $title->getPrefixedText() );
1291 return [ $title, $foreignTitle ];
1298 private function openReader() {
1302 $oldDisable = @libxml_disable_entity_loader(
false );
1304 if ( PHP_VERSION_ID >= 80000 ) {
1306 $reader = XMLReader::open(
1307 'uploadsource://' . $this->sourceAdapterId,
null, LIBXML_PARSEHUGE );
1308 if ( $reader instanceof XMLReader ) {
1309 $this->reader = $reader;
1316 $this->reader =
new XMLReader;
1317 $status = $this->reader->open(
1318 'uploadsource://' . $this->sourceAdapterId,
null, LIBXML_PARSEHUGE );
1321 $error = libxml_get_last_error();
1323 @libxml_disable_entity_loader( $oldDisable );
1324 throw new RuntimeException(
1325 'Encountered an internal error while initializing WikiImporter object: ' . $error->message
1329 @libxml_disable_entity_loader( $oldDisable );
1335 private function syntaxCheckXML() {
1339 AtEase::suppressWarnings();
1340 $oldDisable = libxml_disable_entity_loader(
false );
1342 while ( $this->reader->read() );
1343 $error = libxml_get_last_error();
1345 $errorMessage =
'XML error at line ' . $error->line .
': ' . $error->message;
1346 wfDebug( __METHOD__ .
': Invalid xml found - ' . $errorMessage );
1347 throw new RuntimeException( $errorMessage );
1350 libxml_disable_entity_loader( $oldDisable );
1351 AtEase::restoreWarnings();
1352 $this->reader->close();
1357 $this->openReader();