r69802 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69801‎ | r69802 | r69803 >
Date:17:11, 23 July 2010
Author:simetrical
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES
@@ -114,6 +114,7 @@
115115 * (bug 24313) The preference to mark edits minor by default was removed,
116116 because it encourages edits to be marked minor accidentally and it can be
117117 easily replicated by custom user scripts for those who really want it.
 118+* Non-file pages can no longer be moved to the file namespace, nor vice versa.
118119
119120 === Bug fixes in 1.17 ===
120121 * (bug 17560) Half-broken deletion moved image files to deletion archive
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3169,6 +3169,7 @@
31703170 'immobile-source-page' => 'This page is not movable.',
31713171 'immobile-target-page' => 'Cannot move to that destination title.',
31723172 'imagenocrossnamespace' => 'Cannot move file to non-file namespace',
 3173+'nonfile-cannot-move-to-file' => 'Cannot move non-file to file namespace',
31733174 'imagetypemismatch' => 'The new file extension does not match its type',
31743175 'imageinvalidfilename' => 'The target file name is invalid',
31753176 'fix-double-redirects' => 'Update any redirects that point to the original title',
Index: trunk/phase3/includes/Title.php
@@ -2899,11 +2899,11 @@
29002900
29012901 // Image-specific checks
29022902 if ( $this->getNamespace() == NS_FILE ) {
 2903+ if ( $nt->getNamespace() != NS_FILE ) {
 2904+ $errors[] = array( 'imagenocrossnamespace' );
 2905+ }
29032906 $file = wfLocalFile( $this );
29042907 if ( $file->exists() ) {
2905 - if ( $nt->getNamespace() != NS_FILE ) {
2906 - $errors[] = array( 'imagenocrossnamespace' );
2907 - }
29082908 if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) {
29092909 $errors[] = array( 'imageinvalidfilename' );
29102910 }
@@ -2915,7 +2915,10 @@
29162916 if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destfile->exists() && wfFindFile( $nt ) ) {
29172917 $errors[] = array( 'file-exists-sharedrepo' );
29182918 }
 2919+ }
29192920
 2921+ if ( $nt->getNamespace() == NS_FILE && $this->getNamespace() != NS_FILE ) {
 2922+ $errors[] = array( 'nonfile-cannot-move-to-file' );
29202923 }
29212924
29222925 if ( $auth ) {
Index: trunk/phase3/maintenance/language/messages.inc
@@ -2145,6 +2145,7 @@
21462146 'immobile-target-page',
21472147 'immobile_namespace',
21482148 'imagenocrossnamespace',
 2149+ 'nonfile-cannot-move-to-file',
21492150 'imagetypemismatch',
21502151 'imageinvalidfilename',
21512152 'fix-double-redirects',

Status & tagging log