(bug 27700) The upload protection can now also be set for files that do not exist.
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 26 Feb 2011 13:51:46 +0000 (13:51 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 26 Feb 2011 13:51:46 +0000 (13:51 +0000)
Sort of follow-up to r79655, adds create to $wgRestrictionTypes in DefaultSettings.php as well and removes it when not applicable.

RELEASE-NOTES
includes/DefaultSettings.php
includes/Title.php

index c19e677..928f710 100644 (file)
@@ -144,6 +144,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 27560) Search queries no longer fail in walloon language
 * (bug 27679) Broken embedded files with special characters longer double HTML
   escaped
+* (bug 27700) The upload protection can now also be set for files that do not
+  exist.
 
 
 === API changes in 1.18 ===
index bdee3f9..5e5fb67 100644 (file)
@@ -3371,9 +3371,9 @@ $wgGroupsRemoveFromSelf = array();
  * You probably shouldn't change this.
  * Translated through restriction-* messages.
  * Title::getRestrictionTypes() will remove restrictions that are not
- * applicable to a specific title (upload currently)
+ * applicable to a specific title (create and upload)
  */
-$wgRestrictionTypes = array( 'edit', 'move', 'upload' );
+$wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' );
 
 /**
  * Rights which can be required for each protection level (via action=protect)
index 409467b..c6c225a 100644 (file)
@@ -4118,13 +4118,21 @@ class Title {
        public function getRestrictionTypes() {
                global $wgRestrictionTypes;
 
-               $types = $this->exists() ? $wgRestrictionTypes : array( 'create' );
+               $types = $wgRestrictionTypes;
 
+               if ( !$this->exists() ) {
+                       # Only the create and upload types are applicable for non-existing titles
+                       $types = array_intersect( $types, array( 'create', 'upload' ) );
+               }
                if ( $this->getNamespace() != NS_FILE ) {
+                       # Remove the upload restriction for non-file titles
                        $types = array_diff( $types, array( 'upload' ) );
                }
 
                wfRunHooks( 'TitleGetRestrictionTypes', array( $this, &$types ) );
+               
+               wfDebug( __METHOD__ . ': applicable restriction types for ' . 
+                       $this->getPrefixedText() . ' are ' . implode( ',', $types ) );
 
                return $types;
        }