From: Bryan Tong Minh Date: Wed, 5 Jan 2011 19:17:36 +0000 (+0000) Subject: (bug 26574) Added 'upload' to $wgRestrictionTypes, allowing upload protected pages... X-Git-Tag: 1.31.0-rc.0~32801 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=718ff89310e8cdf6763d9bb3f03225cc4ec70639;p=lhc%2Fweb%2Fwiklou.git (bug 26574) Added 'upload' to $wgRestrictionTypes, allowing upload protected pages to be queried via the API and Special:ProtectedPages, and allowing disabling upload protection by removing it from $wgRestrictionTypes. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 500e7150ea..a1cbb4c877 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -56,6 +56,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN link has a % sign in it. * (bug 26412) Search results headers no longer show a bogus edit link. * (bug 26540) Fixed wrong call to applyPatch in MysqlUpdater +* (bug 26574) Added 'upload' to $wgRestrictionTypes, allowing upload protected + pages to be queried via the API and Special:ProtectedPages, and allowing + disabling upload protection by removing it from $wgRestrictionTypes. === API changes in 1.18 === * (bug 26339) Throw warning when truncating an overlarge API result diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 8b30f5ed53..3da6ec7dfd 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3344,8 +3344,10 @@ $wgGroupsRemoveFromSelf = array(); * Set of available actions that can be restricted via action=protect * 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) */ -$wgRestrictionTypes = array( 'edit', 'move' ); +$wgRestrictionTypes = array( 'edit', 'move', 'upload' ); /** * Rights which can be required for each protection level (via action=protect) diff --git a/includes/Skin.php b/includes/Skin.php index 8d12aa1c4b..849223f451 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -504,7 +504,7 @@ class Skin extends Linker { 'wgCategories' => $wgOut->getCategories(), 'wgBreakFrames' => $wgOut->getFrameOptions() == 'DENY', ); - foreach ( $wgRestrictionTypes as $type ) { + foreach ( $wgTitle->getRestrictionTypes() as $type ) { $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type ); } if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) { diff --git a/includes/Title.php b/includes/Title.php index d7fb38b89c..9bb7137bd6 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4116,14 +4116,15 @@ class Title { */ public function getRestrictionTypes() { global $wgRestrictionTypes; + $types = $this->exists() ? $wgRestrictionTypes : array( 'create' ); - if ( $this->getNamespace() == NS_FILE ) { - $types[] = 'upload'; + if ( $this->getNamespace() != NS_FILE && in_array( 'upload', $types ) ) { + $types = array_diff( $types, array( 'upload' ) ); } - + wfRunHooks( 'TitleGetRestrictionTypes', array( $this, &$types ) ); - + return $types; }