aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/Title.php27
-rw-r--r--includes/api/ApiQueryAllpages.php4
-rw-r--r--includes/specials/SpecialProtectedpages.php4
3 files changed, 23 insertions, 12 deletions
diff --git a/includes/Title.php b/includes/Title.php
index c6c225ab211f..d69610f4f41d 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -4116,14 +4116,8 @@ class Title {
* @return array applicable restriction types
*/
public function getRestrictionTypes() {
- global $wgRestrictionTypes;
-
- $types = $wgRestrictionTypes;
+ $types = self::getFilteredRestrictionTypes( $this->exists() );
- 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' ) );
@@ -4136,6 +4130,25 @@ class Title {
return $types;
}
+ /**
+ * Get a filtered list of all restriction types supported by this wiki.
+ * @param bool $exists True to get all restriction types that apply to
+ * titles that do exist, False for all restriction types that apply to
+ * titles that do not exist
+ * @return array
+ */
+ public static function getFilteredRestrictionTypes( $exists = true ) {
+ global $wgRestrictionTypes;
+ $types = $wgRestrictionTypes;
+ if ( $exists ) {
+ # Remove the create restriction for existing titles
+ $types = array_diff( $types, array( 'create' ) );
+ } else {
+ # Only the create and upload restrictions apply to non-existing titles
+ $types = array_intersect( $types, array( 'create', 'upload' ) );
+ }
+ return $types;
+ }
/**
* Returns the raw sort key to be used for categories, with the specified
diff --git a/includes/api/ApiQueryAllpages.php b/includes/api/ApiQueryAllpages.php
index b396f37e87c3..a804fd5812e3 100644
--- a/includes/api/ApiQueryAllpages.php
+++ b/includes/api/ApiQueryAllpages.php
@@ -195,7 +195,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
}
public function getAllowedParams() {
- global $wgRestrictionTypes, $wgRestrictionLevels;
+ global $wgRestrictionLevels;
return array(
'from' => null,
@@ -220,7 +220,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
ApiBase::PARAM_TYPE => 'integer',
),
'prtype' => array(
- ApiBase::PARAM_TYPE => $wgRestrictionTypes,
+ ApiBase::PARAM_TYPE => Title::getFilteredRestrictionTypes( true ),
ApiBase::PARAM_ISMULTI => true
),
'prlevel' => array(
diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php
index e664c20d4865..c676aa001d62 100644
--- a/includes/specials/SpecialProtectedpages.php
+++ b/includes/specials/SpecialProtectedpages.php
@@ -224,13 +224,11 @@ class SpecialProtectedpages extends SpecialPage {
* @return string Formatted HTML
*/
protected function getTypeMenu( $pr_type ) {
- global $wgRestrictionTypes;
-
$m = array(); // Temporary array
$options = array();
// First pass to load the log names
- foreach( $wgRestrictionTypes as $type ) {
+ foreach( Title::getFilteredRestrictionTypes( true ) as $type ) {
$text = wfMsg("restriction-$type");
$m[$text] = $type;
}