From b18cce5784deac35c67278112c894866496ca36a Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 26 Apr 2012 12:08:21 +0200 Subject: [PATCH] allow namespace caches to be reset for testing --- includes/Namespace.php | 6 ++++-- languages/Language.php | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) 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; } /** -- 2.20.1