Can't activate smw on custom namespace

From semantic-mediawiki.org
Edited by another user.
Last edit: 16:43, 7 December 2018

Hi,
I have created a 'Bibliography' namespace, using the usual Mediawiki procedure. This is what I added in LocalSettings.php:

define("NS_BIBLIOGRAPHY", 3000);
define("NS_BIBLIOGRAPHY_TALK", 3001);
$wgExtraNamespaces[NS_BIBLIOGRAPHY] = "Bibliography";
$wgExtraNamespaces[NS_BIBLIOGRAPHY_TALK] = "Bibliography_talk";

The new namespace was successfully created. Then I activated smw on the new namespace, using: $smwgNamespacesWithSemanticLinks[NS_BIBLIOGRAPHY] = true;

When I run the update script I have this php message

PHP Notice: Use of undefined constant NS_BIBLIOGRAPHY - assumed 'NS_BIBLIOGRAPHY' in /var/lib/mediawiki/LocalSettings.php on line 251

The line is that one of $smwgNamespacesWithSemanticLinks, so I changed the NS_BIBLIOGRAPHY to 'NS_BIBLIOGRAPHY'. Anyway also after this change, smw doesn't work on the new namespace, even after rebuildData.php.
Any ideas?
My configuration is the following

MediaWiki 1.31.1
PHP 7.0.32-0ubuntu0.16.04.1 (apache2handler)
MySQL 5.7.24-0ubuntu0.16.04.1
ICU 55.1
Elasticsearch 5.6.1
Lua 5.1.5
SMW 3.0

Thanks for any help! Lorenzo

11:24, 7 December 2018

As always I am somewhat amazed why people constantly fail to configure this. You are not alone here and I do not know why. Anyways here is how you do this and the order is imperative.

## Define custom namespaces // Must set before invoking Semantic MediaWiki
define( 'NS_BIBLIOGRAPHY', 3000 );
define( 'NS_BIBLIOGRAPHY_TALK', 3001 );

## Name custom namespaces // Must set before invoking Semantic MediaWiki
$wgExtraNamespaces[NS_BIBLIOGRAPHY] = 'Bibliography';
$wgExtraNamespaces[NS_BIBLIOGRAPHY_TALK] = 'Bibliography_talk';

## Semantic MediaWiki
enableSemantics( www.example.com );
$smwgNamespacesWithSemanticLinks[NS_BIBLIOGRAPHY] = true; // Must set after invoking Semantic MediaWiki
16:49, 7 December 2018

Well, you are right that was exactly the problem. I am sorry I didn't check carefully documentation and older discussions.

Thanks for the help! Bye,
Lorenzo

09:43, 10 December 2018