allow namespace caches to be reset for testing
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 26 Apr 2012 10:08:21 +0000 (12:08 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Thu, 26 Apr 2012 10:08:21 +0000 (12:08 +0200)
includes/Namespace.php
languages/Language.php

index ac788aa..a7b00f3 100644 (file)
@@ -186,12 +186,14 @@ class MWNamespace {
         * Returns array of all defined namespaces with their canonical
         * (English) names.
         *
+        * @param bool $rebuild rebuild namespace list (default = false). Used for testing.
+        *
         * @return array
         * @since 1.17
         */
-       public static function getCanonicalNamespaces() {
+       public static function getCanonicalNamespaces( $rebuild = false ) {
                static $namespaces = null;
-               if ( $namespaces === null ) {
+               if ( $namespaces === null || $rebuild ) {
                        global $wgExtraNamespaces, $wgCanonicalNamespaceNames;
                        $namespaces = array( NS_MAIN => '' ) + $wgCanonicalNamespaceNames;
                        if ( is_array( $wgExtraNamespaces ) ) {
index e6feb45..07445b7 100644 (file)
@@ -392,6 +392,16 @@ class Language {
         */
        public function setNamespaces( array $namespaces ) {
                $this->namespaceNames = $namespaces;
+               $this->mNamespaceIds = null;
+       }
+
+       /**
+        * Resets all of the namespace caches. Mainly used for testing
+        */
+       public function resetNamespaces( ) {
+               $this->namespaceNames = null;
+               $this->mNamespaceIds = null;
+               $this->namespaceAliases = null;
        }
 
        /**