http://www.mediawiki.org/wiki/Special:Code/MediaWiki/82853
Revision: 82853
Author: btongminh
Date: 2011-02-26 13:51:46 +0000 (Sat, 26 Feb 2011)
Log Message:
-----------
(bug 27700) The upload protection can now also be set for files that do not
exist.
Sort of follow-up to r79655, adds create to $wgRestrictionTypes in
DefaultSettings.php as well and removes it when not applicable.
Modified Paths:
--------------
trunk/phase3/RELEASE-NOTES
trunk/phase3/includes/DefaultSettings.php
trunk/phase3/includes/Title.php
Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES 2011-02-26 13:51:03 UTC (rev 82852)
+++ trunk/phase3/RELEASE-NOTES 2011-02-26 13:51:46 UTC (rev 82853)
@@ -144,6 +144,8 @@
* (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 ===
Modified: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php 2011-02-26 13:51:03 UTC (rev
82852)
+++ trunk/phase3/includes/DefaultSettings.php 2011-02-26 13:51:46 UTC (rev
82853)
@@ -3371,9 +3371,9 @@
* 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)
Modified: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php 2011-02-26 13:51:03 UTC (rev 82852)
+++ trunk/phase3/includes/Title.php 2011-02-26 13:51:46 UTC (rev 82853)
@@ -4118,13 +4118,21 @@
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;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs