From f4aba377e31ad1fc0287ded2fd5d4f4dc3d5317a Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 23 Jul 2010 17:11:30 +0000 Subject: [PATCH] Prohibit all moves from/to file namespace Per discussion on wikitech-l. Previously, it was possible to move pages to the file namespace, and move pages from the file namespace as long as there was no associated file. --- RELEASE-NOTES | 1 + includes/Title.php | 9 ++++++--- languages/messages/MessagesEn.php | 1 + maintenance/language/messages.inc | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c93e01a7ff..e8ec3bbbea 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -114,6 +114,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 24313) The preference to mark edits minor by default was removed, because it encourages edits to be marked minor accidentally and it can be easily replicated by custom user scripts for those who really want it. +* Non-file pages can no longer be moved to the file namespace, nor vice versa. === Bug fixes in 1.17 === * (bug 17560) Half-broken deletion moved image files to deletion archive diff --git a/includes/Title.php b/includes/Title.php index e515783667..9d2f4c9abe 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2899,11 +2899,11 @@ class Title { // Image-specific checks if ( $this->getNamespace() == NS_FILE ) { + if ( $nt->getNamespace() != NS_FILE ) { + $errors[] = array( 'imagenocrossnamespace' ); + } $file = wfLocalFile( $this ); if ( $file->exists() ) { - if ( $nt->getNamespace() != NS_FILE ) { - $errors[] = array( 'imagenocrossnamespace' ); - } if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) { $errors[] = array( 'imageinvalidfilename' ); } @@ -2915,7 +2915,10 @@ class Title { if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destfile->exists() && wfFindFile( $nt ) ) { $errors[] = array( 'file-exists-sharedrepo' ); } + } + if ( $nt->getNamespace() == NS_FILE && $this->getNamespace() != NS_FILE ) { + $errors[] = array( 'nonfile-cannot-move-to-file' ); } if ( $auth ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 5760519097..88f3ffa61c 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3169,6 +3169,7 @@ cannot move a page over itself.', 'immobile-source-page' => 'This page is not movable.', 'immobile-target-page' => 'Cannot move to that destination title.', 'imagenocrossnamespace' => 'Cannot move file to non-file namespace', +'nonfile-cannot-move-to-file' => 'Cannot move non-file to file namespace', 'imagetypemismatch' => 'The new file extension does not match its type', 'imageinvalidfilename' => 'The target file name is invalid', 'fix-double-redirects' => 'Update any redirects that point to the original title', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 066aa89967..e032ddb418 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2145,6 +2145,7 @@ $wgMessageStructure = array( 'immobile-target-page', 'immobile_namespace', 'imagenocrossnamespace', + 'nonfile-cannot-move-to-file', 'imagetypemismatch', 'imageinvalidfilename', 'fix-double-redirects', -- 2.20.1