(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.
This commit is contained in:
Bryan Tong Minh 2011-02-26 13:51:46 +00:00
parent 980c3db8a5
commit f664cf10ef
3 changed files with 13 additions and 3 deletions

View 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 ===

View 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)

View 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;
}