allow namespace caches to be reset for testing

This commit is contained in:
daniel 2012-04-26 12:08:21 +02:00
parent 2b740d448a
commit b18cce5784
2 changed files with 14 additions and 2 deletions

View 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 ) ) {

View 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;
}
/**