Migrate block log to new log system
[lhc/web/wiklou.git] / includes / specials / SpecialImport.php
index 05bb607..aa9b0f4 100644 (file)
@@ -47,17 +47,20 @@ class SpecialImport extends SpecialPage {
         */
        public function __construct() {
                parent::__construct( 'Import', 'import' );
-               $this->namespace = $this->getConfig()->get( 'ImportTargetNamespace' );
        }
 
        /**
         * Execute
         * @param string|null $par
+        * @throws PermissionsError
+        * @throws ReadOnlyError
         */
        function execute( $par ) {
                $this->setHeaders();
                $this->outputHeader();
 
+               $this->namespace = $this->getConfig()->get( 'ImportTargetNamespace' );
+
                $this->getOutput()->addModules( 'mediawiki.special.import' );
 
                $user = $this->getUser();
@@ -157,7 +160,7 @@ class SpecialImport extends SpecialPage {
                                array( 'importfailed', $source->getWikiText() )
                        );
                } else {
-                       $importer = new WikiImporter( $source->value );
+                       $importer = new WikiImporter( $source->value, $this->getConfig() );
                        if ( !is_null( $this->namespace ) ) {
                                $importer->setTargetNamespace( $this->namespace );
                        }
@@ -191,7 +194,7 @@ class SpecialImport extends SpecialPage {
                        $reporter->open();
                        try {
                                $importer->doImport();
-                       } catch ( MWException $e ) {
+                       } catch ( Exception $e ) {
                                $exception = $e;
                        }
                        $result = $reporter->close();
@@ -518,13 +521,14 @@ class ImportReporter extends ContextSource {
 
        /**
         * @param Title $title
-        * @param Title $origTitle
+        * @param ForeignTitle $foreignTitle
         * @param int $revisionCount
         * @param int $successCount
         * @param array $pageInfo
         * @return void
         */
-       function reportPage( $title, $origTitle, $revisionCount, $successCount, $pageInfo ) {
+       function reportPage( $title, $foreignTitle, $revisionCount,
+                       $successCount, $pageInfo ) {
                $args = func_get_args();
                call_user_func_array( $this->mOriginalPageOutCallback, $args );
 
@@ -553,7 +557,7 @@ class ImportReporter extends ContextSource {
                                $log->addEntry( 'upload', $title, $detail, array(), $this->getUser() );
                        } else {
                                $interwiki = '[[:' . $this->mInterwiki . ':' .
-                                       $origTitle->getPrefixedText() . ']]';
+                                       $foreignTitle->getFullText() . ']]';
                                $detail = $this->msg( 'import-logentry-interwiki-detail' )->numParams(
                                        $successCount )->params( $interwiki )->inContentLanguage()->text();
                                if ( $this->reason ) {
@@ -579,7 +583,7 @@ class ImportReporter extends ContextSource {
                                $page = WikiPage::factory( $title );
                                # Update page record
                                $page->updateRevisionOn( $dbw, $nullRevision );
-                               wfRunHooks(
+                               Hooks::run(
                                        'NewRevisionFromEditComplete',
                                        array( $page, $nullRevision, $latest, $this->getUser() )
                                );