From 2ed55f42e40199641397e9cd2fa5ae908a8b353f Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Tue, 6 Sep 2011 00:01:06 +0000 Subject: [PATCH] (bug 23057) Importers can 'edit' or 'create' a fully-protected page by importing a new revision into it --- includes/Import.php | 15 ++++++++++++++- languages/messages/MessagesEn.php | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/includes/Import.php b/includes/Import.php index 9fb79e28e5..0a1824ca16 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -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 ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 27ac899ae4..d30604b522 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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', -- 2.20.1