Page MenuHomePhabricator

Language::getNamespaces() produce fatal cause it sum array with null
Open, LowPublic

Description

Fatal error: Unsupported operand types in /www/sandwiki/languages/Language.php on line 362

When running my own unit tests.

Caused by this line in my LocalSettings.php

$wgLocalisationCacheConf['manualRecache'] = true;

The test suite should overwrite that.


Version: 1.20.x
Severity: normal

Details

Reference
bz36468

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:19 AM
bzimport set Reference to bz36468.
bzimport added a subscriber: Unknown Object (MLST).

I can not reproduce the issue. Please provide a stack trace and the name of test that cause the error.

Language::getNamespaces() seems to be summing array which does not work whenever one of the operand is null instead of an empty array.

Code is:

$this->namespaceNames = self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
$validNamespaces = MWNamespace::getCanonicalNamespaces();
$this->namespaceNames = $wgExtraNamespaces + $this->namespaceNames + $validNamespaces;

Most probably the data cache is empty / corrupted and $this->namespaceNames ends up being null which break the sum.

Two possibles fixes would be:

  • use array_merge() if it supports merging an array with a null value
  • throw a nice exception whenever the getItem calls returns null

Redirecting to General component since that is not really related to unit tests.

Didn't I explain the issue clearly? If the cache is out of date (or not existing) and automatic cache creation is disabled, $dataCache->getItem returns null.

The fix is to enable automatic cache creation for unit tests.

I'm sure I've seen this on the error logs of the cluster