r82858 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82857‎ | r82858 | r82859 >
Date:16:29, 26 February 2011
Author:btongminh
Status:ok
Tags:
Comment:
Follow-up r82853: Filter out create restriction from SpecialProtectedPages and Api. Added Title::getFilteredRestrictionTypes() for this purpose.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialProtectedpages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -195,7 +195,7 @@
196196 }
197197
198198 public function getAllowedParams() {
199 - global $wgRestrictionTypes, $wgRestrictionLevels;
 199+ global $wgRestrictionLevels;
200200
201201 return array(
202202 'from' => null,
@@ -220,7 +220,7 @@
221221 ApiBase::PARAM_TYPE => 'integer',
222222 ),
223223 'prtype' => array(
224 - ApiBase::PARAM_TYPE => $wgRestrictionTypes,
 224+ ApiBase::PARAM_TYPE => Title::getFilteredRestrictionTypes( true ),
225225 ApiBase::PARAM_ISMULTI => true
226226 ),
227227 'prlevel' => array(
Index: trunk/phase3/includes/Title.php
@@ -4116,14 +4116,8 @@
41174117 * @return array applicable restriction types
41184118 */
41194119 public function getRestrictionTypes() {
4120 - global $wgRestrictionTypes;
 4120+ $types = self::getFilteredRestrictionTypes( $this->exists() );
41214121
4122 - $types = $wgRestrictionTypes;
4123 -
4124 - if ( !$this->exists() ) {
4125 - # Only the create and upload types are applicable for non-existing titles
4126 - $types = array_intersect( $types, array( 'create', 'upload' ) );
4127 - }
41284122 if ( $this->getNamespace() != NS_FILE ) {
41294123 # Remove the upload restriction for non-file titles
41304124 $types = array_diff( $types, array( 'upload' ) );
@@ -4136,6 +4130,25 @@
41374131
41384132 return $types;
41394133 }
 4134+ /**
 4135+ * Get a filtered list of all restriction types supported by this wiki.
 4136+ * @param bool $exists True to get all restriction types that apply to
 4137+ * titles that do exist, False for all restriction types that apply to
 4138+ * titles that do not exist
 4139+ * @return array
 4140+ */
 4141+ public static function getFilteredRestrictionTypes( $exists = true ) {
 4142+ global $wgRestrictionTypes;
 4143+ $types = $wgRestrictionTypes;
 4144+ if ( $exists ) {
 4145+ # Remove the create restriction for existing titles
 4146+ $types = array_diff( $types, array( 'create' ) );
 4147+ } else {
 4148+ # Only the create and upload restrictions apply to non-existing titles
 4149+ $types = array_intersect( $types, array( 'create', 'upload' ) );
 4150+ }
 4151+ return $types;
 4152+ }
41404153
41414154 /**
41424155 * Returns the raw sort key to be used for categories, with the specified
Index: trunk/phase3/includes/specials/SpecialProtectedpages.php
@@ -224,13 +224,11 @@
225225 * @return string Formatted HTML
226226 */
227227 protected function getTypeMenu( $pr_type ) {
228 - global $wgRestrictionTypes;
229 -
230228 $m = array(); // Temporary array
231229 $options = array();
232230
233231 // First pass to load the log names
234 - foreach( $wgRestrictionTypes as $type ) {
 232+ foreach( Title::getFilteredRestrictionTypes( true ) as $type ) {
235233 $text = wfMsg("restriction-$type");
236234 $m[$text] = $type;
237235 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r831541.17wmf1: MFT r82836, r82853, r82858, r83114catrope18:19, 3 March 2011
r85354MFT r82518, r82530, r82538, r82547, r82550, r82565, r82572, r82608, r82696, r...demon18:25, 4 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82853(bug 27700) The upload protection can now also be set for files that do not e...btongminh13:51, 26 February 2011

Status & tagging log