Difference between revisions of "Talk:WikiDB/Configuration settings"

From TestWiki
Jump to: navigation, search
(Created page with "== Warning and no table creation == Hi! The following code is bogus : <php>$wgWikiDBNamespaces = 100;</php> $wgWikiDBNamespaces is expected to be an array (in classWikiDB_Ta...")
 
(Warning and no table creation)
Line 16: Line 16:
 
$wgWikiDBNamespaces = array(NS_TABLE => true);
 
$wgWikiDBNamespaces = array(NS_TABLE => true);
 
</php>
 
</php>
 +
 +
----
 +
 +
: Hi - thanks for the bug report.
 +
: The extension has code to handle this, in WikiDB.php:
 +
<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);
 +
}
 +
</php>
 +
: However, this only works if you define the properties before you include the extension.  If you moved your <code>require_once</code> line so that it comes after <code>$wgWikiDBNamespaces</code> 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,
 +
: --[[User:HappyDog|HappyDog]] ([[User talk:HappyDog|talk]]) 22:10, 24 November 2019 (GMT)

Revision as of 23:11, 24 November 2019

Warning and no table creation

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)