(bug 23057) Importers can 'edit' or 'create' a fully-protected page by importing...
authorRobin Pepermans <robin@users.mediawiki.org>
Tue, 6 Sep 2011 00:01:06 +0000 (00:01 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Tue, 6 Sep 2011 00:01:06 +0000 (00:01 +0000)
includes/Import.php
languages/messages/MessagesEn.php

index 9fb79e2..0a1824c 100644 (file)
@@ -712,7 +712,12 @@ class WikiImporter {
                return $info;
        }
 
+       /**
+        * @return Array or false
+        */
        private function processTitle( $text ) {
+               global $wgCommandLineMode;
+
                $workTitle = $text;
                $origTitle = Title::newFromText( $workTitle );
 
@@ -724,12 +729,20 @@ class WikiImporter {
                }
 
                if( is_null( $title ) ) {
-                       // Invalid page title? Ignore the page
+                       # Invalid page title? Ignore the page
                        $this->notice( "Skipping invalid page title '$workTitle'" );
                        return false;
                } elseif( $title->getInterwiki() != '' ) {
                        $this->notice( "Skipping interwiki page title '$workTitle'" );
                        return false;
+               } elseif( !$title->userCan( 'edit' ) && !$wgCommandLineMode ) {
+                       # Do not import if the importing wiki user cannot edit this page
+                       $this->notice( wfMessage( 'import-error-edit', $title->getText() )->text() );
+                       return false;
+               } elseif( !$title->exists() && !$title->userCan( 'create' ) && !$wgCommandLineMode ) {
+                       # Do not import if the importing wiki user cannot create this page
+                       $this->notice( wfMessage( 'import-error-create', $title->getText() )->text() );
+                       return false;
                }
 
                return array( $title, $origTitle );
index 27ac899..d30604b 100644 (file)
@@ -3370,6 +3370,8 @@ A temporary folder is missing.',
 'import-token-mismatch'      => 'Loss of session data.
 Please try again.',
 'import-invalid-interwiki'   => 'Cannot import from the specified wiki.',
+'import-error-edit'          => 'Page "$1" is not imported because you are not allowed to edit it.',
+'import-error-create'        => 'Page "$1" is not imported because you are not allowed to create it.',
 
 # Import log
 'importlogpage'                    => 'Import log',