r79655 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79654‎ | r79655 | r79656 >
Date:19:17, 5 January 2011
Author:btongminh
Status:ok (Comments)
Tags:
Comment:
(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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -4116,14 +4116,15 @@
41174117 */
41184118 public function getRestrictionTypes() {
41194119 global $wgRestrictionTypes;
 4120+
41204121 $types = $this->exists() ? $wgRestrictionTypes : array( 'create' );
41214122
4122 - if ( $this->getNamespace() == NS_FILE ) {
4123 - $types[] = 'upload';
 4123+ if ( $this->getNamespace() != NS_FILE && in_array( 'upload', $types ) ) {
 4124+ $types = array_diff( $types, array( 'upload' ) );
41244125 }
4125 -
 4126+
41264127 wfRunHooks( 'TitleGetRestrictionTypes', array( $this, &$types ) );
4127 -
 4128+
41284129 return $types;
41294130 }
41304131
Index: trunk/phase3/includes/DefaultSettings.php
@@ -3344,8 +3344,10 @@
33453345 * Set of available actions that can be restricted via action=protect
33463346 * You probably shouldn't change this.
33473347 * Translated through restriction-* messages.
 3348+ * Title::getRestrictionTypes() will remove restrictions that are not
 3349+ * applicable to a specific title (upload currently)
33483350 */
3349 -$wgRestrictionTypes = array( 'edit', 'move' );
 3351+$wgRestrictionTypes = array( 'edit', 'move', 'upload' );
33503352
33513353 /**
33523354 * Rights which can be required for each protection level (via action=protect)
Index: trunk/phase3/includes/Skin.php
@@ -504,7 +504,7 @@
505505 'wgCategories' => $wgOut->getCategories(),
506506 'wgBreakFrames' => $wgOut->getFrameOptions() == 'DENY',
507507 );
508 - foreach ( $wgRestrictionTypes as $type ) {
 508+ foreach ( $wgTitle->getRestrictionTypes() as $type ) {
509509 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
510510 }
511511 if ( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
Index: trunk/phase3/RELEASE-NOTES
@@ -56,6 +56,9 @@
5757 link has a % sign in it.
5858 * (bug 26412) Search results headers no longer show a bogus edit link.
5959 * (bug 26540) Fixed wrong call to applyPatch in MysqlUpdater
 60+* (bug 26574) Added 'upload' to $wgRestrictionTypes, allowing upload protected
 61+ pages to be queried via the API and Special:ProtectedPages, and allowing
 62+ disabling upload protection by removing it from $wgRestrictionTypes.
6063
6164 === API changes in 1.18 ===
6265 * (bug 26339) Throw warning when truncating an overlarge API result

Follow-up revisions

RevisionCommit summaryAuthorDate
r79660Follow-up r79655: array_diff makes in_array unnecessarybtongminh19:58, 5 January 2011
r797201.17: MFT r79578, r79591, r79593, r79595, r79649, r79650, r79651, r79653, r79...catrope14:48, 6 January 2011
r79740Remove unused global $wgRestrictionTypes, changed into Title::getRestrictionT...platonides18:15, 6 January 2011
r82853(bug 27700) The upload protection can now also be set for files that do not e...btongminh13:51, 26 February 2011

Comments

#Comment by Ilmari Karonen (talk | contribs)   19:44, 5 January 2011

Hmm, isn't that in_array( 'upload', $types ) there basically a no-op? If 'upload' isn't in $types, then array_diff() should just do nothing.

#Comment by Catrope (talk | contribs)   19:57, 5 January 2011

That's right

#Comment by Bryan (talk | contribs)   19:58, 5 January 2011
#Comment by Platonides (talk | contribs)   18:15, 6 January 2011

SpecialProtectedpages.php seems to need a change into Title::getRestrictionTypes(), too.

#Comment by Bryan (talk | contribs)   18:41, 6 January 2011

No, because Title::getRestrictionTypes() returns the applicable restrictions for this title, whereas SpecialProtectedPages requires all restrictions.

Status & tagging log