From: daniel Date: Thu, 26 Apr 2012 10:08:21 +0000 (+0200) Subject: allow namespace caches to be reset for testing X-Git-Tag: 1.31.0-rc.0~22097^2^2~195 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=b18cce5784deac35c67278112c894866496ca36a;p=lhc%2Fweb%2Fwiklou.git allow namespace caches to be reset for testing --- diff --git a/includes/Namespace.php b/includes/Namespace.php index ac788aaaac..a7b00f3595 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -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 ) ) { diff --git a/languages/Language.php b/languages/Language.php index e6feb45edf..07445b7c98 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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; } /**