Talk:WikiDB/Configuration settings

From TestWiki
Jump to: navigation, search

Warning and no table creation[edit]

Hi! The following code is bogus :

$wgWikiDBNamespaces = 100;

$wgWikiDBNamespaces is expected to be an array (in classWikiDB_Table.php line 232), so this code generate a warning and no table creation.

the good way to create the namespace in LocalSettings.php is:

require_once "$IP/extensions/WikiDB/WikiDB.php";
define('NS_TABLE', 100);
define('NS_TABLE_TALK', 101);
$wgExtraNamespaces[NS_TABLE] = "Table";
$wgExtraNamespaces[NS_TABLE_TALK] = "Table_Talk";
$wgWikiDBNamespaces = array(NS_TABLE => true);

Hi - thanks for the bug report.
The extension has code to handle this, in WikiDB.php:
// If $wgWikiDBNamespaces has not been set, or is otherwise blank, initialise it to
// an empty array.
	if (IsBlank(@$wgWikiDBNamespaces)) {
		$wgWikiDBNamespaces = array();
	}
// Otherwise, if it has been set, make sure it's a valid array.
// In this case the value is treated as the namespace ID of a single table
// namespace, which we convert to the standard array representation used by this
// variable.
	elseif (!is_array($wgWikiDBNamespaces)) {
		$wgWikiDBNamespaces = array($wgWikiDBNamespaces => true);
	}
However, this only works if you define the properties before you include the extension. If you moved your require_once line so that it comes after $wgWikiDBNamespaces is defined, then things would work as intended.
This is a bug - it is normal to include the extension before configuring it, and so we should definitely support this. I will include a fix for this in the next release.
Kind regards,
--HappyDog (talk) 22:10, 24 November 2019 (GMT)
This issue was fixed in WikiDB 5.0.3. --HappyDog (talk) 00:43, 8 April 2021 (BST)