r69922 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69921‎ | r69922 | r69923 >
Date:22:29, 25 July 2010
Author:platonides
Status:ok
Tags:
Comment:
Move getValidNamespaces() to Namespace.php
Modified paths:
  • /trunk/phase3/includes/Namespace.php (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiBase.php
@@ -329,7 +329,7 @@
330330 switch ( $type ) {
331331 case 'namespace':
332332 // Special handling because namespaces are type-limited, yet they are not given
333 - $desc .= $paramPrefix . $prompt . implode( ', ', ApiBase::getValidNamespaces() );
 333+ $desc .= $paramPrefix . $prompt . implode( ', ', MWNamespace::getValidNamespaces() );
334334 break;
335335 case 'limit':
336336 $desc .= $paramPrefix . "No more than {$paramSettings[self :: PARAM_MAX]} ({$paramSettings[self::PARAM_MAX2]} for bots) allowed";
@@ -524,24 +524,10 @@
525525 }
526526
527527 /**
528 - * Returns an array of the namespaces (by integer id) that exist on the
529 - * wiki. Used primarily in help documentation.
530 - * @return array
 528+ * @deprecated use MWNamespace::getValidNamespaces()
531529 */
532530 public static function getValidNamespaces() {
533 - static $mValidNamespaces = null;
534 -
535 - if ( is_null( $mValidNamespaces ) ) {
536 - global $wgCanonicalNamespaceNames;
537 - $mValidNamespaces = array( NS_MAIN ); // Doesn't appear in $wgCanonicalNamespaceNames for some reason
538 - foreach ( array_keys( $wgCanonicalNamespaceNames ) as $ns ) {
539 - if ( $ns > 0 ) {
540 - $mValidNamespaces[] = $ns;
541 - }
542 - }
543 - }
544 -
545 - return $mValidNamespaces;
 531+ return MWNamespace::getValidNamespaces();
546532 }
547533
548534 /**
@@ -649,7 +635,7 @@
650636 $value = $this->getMain()->getRequest()->getVal( $encParamName, $default );
651637
652638 if ( isset( $value ) && $type == 'namespace' ) {
653 - $type = ApiBase::getValidNamespaces();
 639+ $type = MWNamespace::getValidNamespaces();
654640 }
655641 }
656642
Index: trunk/phase3/includes/Namespace.php
@@ -156,6 +156,27 @@
157157 }
158158
159159 /**
 160+ * Returns an array of the namespaces (by integer id) that exist on the
 161+ * wiki. Used primarily by the api in help documentation.
 162+ * @return array
 163+ */
 164+ public static function getValidNamespaces() {
 165+ static $mValidNamespaces = null;
 166+
 167+ if ( is_null( $mValidNamespaces ) ) {
 168+ global $wgCanonicalNamespaceNames;
 169+ $mValidNamespaces = array( NS_MAIN ); // Doesn't appear in $wgCanonicalNamespaceNames for some reason
 170+ foreach ( array_keys( $wgCanonicalNamespaceNames ) as $ns ) {
 171+ if ( $ns > 0 ) {
 172+ $mValidNamespaces[] = $ns;
 173+ }
 174+ }
 175+ }
 176+
 177+ return $mValidNamespaces;
 178+ }
 179+
 180+ /**
160181 * Can this namespace ever have a talk namespace?
161182 *
162183 * @param $index Int: namespace index

Status & tagging log