Mailing List Archive

Newby dev question: extension configuration variable
Hi,

in my first attempt at jumping into improving a mediawiki extension, I am failing at a very basic step.

I want to make the extension configurable and followed this advice:
[ https://www.mediawiki.org/wiki/Manual:Configuration_for_developers | https://www.mediawiki.org/wiki/Manual:Configuration_for_developers ]


this is my extension.json I added:

"config": {
"ShariffServices": {
"value": "["twitter","facebook","pinterest"]",
"description": "configuration of available services"
}
},
"ConfigRegistry": {
"Shariff": "GlobalVarConfig::newInstance"
},

now in the baisc PHP file of the extension, I am trying
use MediaWiki\MediaWikiServices;
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'Shariff' );
$services = $config->get ('Services');

but the last line leads to
[XtqcaewKU0Q3UCukKmZO9AAAABM] /index.php?title=Main_Page Error from line 3061 of ../includes/parser/Parser.php: Call to a member function matchStartAndRemove() on null

Backtrace:

#0 ..includes/parser/Preprocessor_DOM.php(1277): Parser->braceSubstitution(array, PPFrame_DOM)
#1 ../includes/parser/Parser.php(2942): PPFrame_DOM->expand(DOMElement, integer)
#2 ../includes/parser/Parser.php(701): Parser->replaceVariables(string, PPFrame_DOM)
#3 ../includes/parser/Parser.php(4717): Parser->preprocess(string, Title, ParserOptions)
#4 ../includes/cache/MessageCache.php(1089): Parser->transformMsg(string, ParserOptions, Title)
#5 ../includes/Message.php(1273): MessageCache->transform(string, boolean, LanguageEn, Title)
#6 ../includes/Message.php(874): Message->transformText(string)
#7 ../includes/Message.php(934): Message->toString(string)
#8 ../includes/OutputPage.php(902): Message->text()
#9 /../includes/OutputPage.php(949): OutputPage->setHTMLTitle(Message)
#10 ../includes/OutputPage.php(2424): OutputPage->setPageTitle(string)
#11 /../includes/exception/MWExceptionRenderer.php(128): OutputPage->prepareErrorPage(string)
#12 ../includes/exception/MWExceptionRenderer.php(54): MWExceptionRenderer::reportHTML(ConfigException)
#13 ../includes/exception/MWExceptionHandler.php(75): MWExceptionRenderer::output(ConfigException, integer)
#14 ../includes/exception/MWExceptionHandler.php(149): MWExceptionHandler::report(ConfigException)
#15 ../includes/MediaWiki.php(551): MWExceptionHandler::handleException(ConfigException)
#16 ../index.php(42): MediaWiki->run()
#17 {main}



What am I doing wrong?


As far is I understand it, using DefaultSettings.php is outdated, we should be using extension.json. But I can't get it to work.


Can anybody point me to a simple extension that uses this mechanism correctly?,





cheers,


Bernhard


_______________________________________________
MediaWiki-l mailing list
To unsubscribe, go to:
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l