X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImport.php;h=60d4a1f8422eb507dda3e201618d591de8c815c0;hb=c54766586acab549f186e81eeab259845112809d;hp=c2fae309525abe762a74625dad69fb516207a47c;hpb=6b4ef9e7c6523075b4f48878e02c9fac77e947ca;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Import.php b/includes/Import.php index c2fae30952..60d4a1f842 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -265,7 +265,7 @@ class WikiImporter { // No rootpage $this->setImportTitleFactory( new NaiveImportTitleFactory() ); } elseif ( $rootpage !== '' ) { - $rootpage = rtrim( $rootpage, '/' ); //avoid double slashes + $rootpage = rtrim( $rootpage, '/' ); // avoid double slashes $title = Title::newFromText( $rootpage ); if ( !$title || $title->isExternal() ) { @@ -394,9 +394,9 @@ class WikiImporter { $countKey = 'title_' . $title->getPrefixedText(); $countable = $page->isCountable( $editInfo ); if ( array_key_exists( $countKey, $this->countableCache ) && - $countable != $this->countableCache[ $countKey ] ) { + $countable != $this->countableCache[$countKey] ) { DeferredUpdates::addUpdate( SiteStatsUpdate::factory( array( - 'articles' => ( (int)$countable - (int)$this->countableCache[ $countKey ] ) + 'articles' => ( (int)$countable - (int)$this->countableCache[$countKey] ) ) ) ); } } @@ -611,7 +611,7 @@ class WikiImporter { $tag = $this->reader->localName; if ( $tag == 'namespace' ) { - $this->foreignNamespaces[ $this->nodeAttribute( 'key' ) ] = + $this->foreignNamespaces[$this->nodeAttribute( 'key' )] = $this->nodeContents(); } elseif ( in_array( $tag, $normalFields ) ) { $siteInfo[$tag] = $this->nodeContents(); @@ -728,13 +728,14 @@ class WikiImporter { $title = $this->processTitle( $pageInfo['title'], isset( $pageInfo['ns'] ) ? $pageInfo['ns'] : null ); - if ( !$title ) { + // $title is either an array of two titles or false. + if ( is_array( $title ) ) { + $this->pageCallback( $title ); + list( $pageInfo['_title'], $foreignTitle ) = $title; + } else { $badTitle = true; $skip = true; } - - $this->pageCallback( $title ); - list( $pageInfo['_title'], $foreignTitle ) = $title; } if ( $title ) { @@ -750,10 +751,17 @@ class WikiImporter { } } - $this->pageOutCallback( $pageInfo['_title'], $foreignTitle, + // @note $pageInfo is only set if a valid $title is processed above with + // no error. If we have a valid $title, then pageCallback is called + // above, $pageInfo['title'] is set and we do pageOutCallback here. + // If $pageInfo['_title'] is not set, then $foreignTitle is also not + // set since they both come from $title above. + if ( array_key_exists( '_title', $pageInfo ) ) { + $this->pageOutCallback( $pageInfo['_title'], $foreignTitle, $pageInfo['revisionCount'], $pageInfo['successfulRevisionCount'], $pageInfo ); + } } /** @@ -1570,8 +1578,7 @@ class WikiRevision { } // avoid memory leak...? - $linkCache = LinkCache::singleton(); - $linkCache->clear(); + Title::clearCaches(); $page = WikiPage::factory( $this->title ); $page->loadPageData( 'fromdbmaster' ); @@ -1606,7 +1613,7 @@ class WikiRevision { 'page' => $pageId, 'content_model' => $this->getModel(), 'content_format' => $this->getFormat(), - //XXX: just set 'content' => $this->getContent()? + // XXX: just set 'content' => $this->getContent()? 'text' => $this->getContent()->serialize( $this->getFormat() ), 'comment' => $this->getComment(), 'user' => $userId, @@ -1647,7 +1654,7 @@ class WikiRevision { 'log_namespace' => $this->getTitle()->getNamespace(), 'log_title' => $this->getTitle()->getDBkey(), 'log_comment' => $this->getComment(), - #'log_user_text' => $this->user_text, + # 'log_user_text' => $this->user_text, 'log_params' => $this->params ), __METHOD__ ); @@ -1665,7 +1672,7 @@ class WikiRevision { 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp( $this->timestamp ), 'log_user' => User::idFromName( $this->user_text ), - #'log_user_text' => $this->user_text, + # 'log_user_text' => $this->user_text, 'log_namespace' => $this->getTitle()->getNamespace(), 'log_title' => $this->getTitle()->getDBkey(), 'log_comment' => $this->getComment(), @@ -1858,9 +1865,9 @@ class ImportStreamSource implements ImportSource { * @return Status */ static function newFromFile( $filename ) { - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); $file = fopen( $filename, 'rt' ); - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); if ( !$file ) { return Status::newFatal( "importcantopen" ); }