Newby dev question: extension configuration variable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Newby dev question: extension configuration variable

Krabina Bernhard
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?


so long,
Bernhard

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Newby dev question: extension configuration variable

Gergo Tisza
It should be $services = $config->get( 'ShariffServices' );

The actual error is an unrelated configuration problem with your wiki (or
possibly a MediaWiki core bug where it tries to use a certain type of error
handling too early in the request lifecycle), that's triggered during
rendering the error about configuration not having a Services key.

On Tue, Jun 16, 2020 at 11:30 AM Krabina Bernhard <[hidden email]> wrote:

> 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":
> "[&quot;twitter&quot;,&quot;facebook&quot;,&quot;pinterest&quot;]",
> "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?
>
>
> so long,
> Bernhard
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: Newby dev question: extension configuration variable

Krabina Bernhard
Thank you, Gergo, this is working fine now!

regards,
Bernhard

----- Am 16. Jun 2020 um 12:48 schrieb Gergo Tisza [hidden email]:

> It should be $services = $config->get( 'ShariffServices' );
>
> The actual error is an unrelated configuration problem with your wiki (or
> possibly a MediaWiki core bug where it tries to use a certain type of error
> handling too early in the request lifecycle), that's triggered during
> rendering the error about configuration not having a Services key.
>
> On Tue, Jun 16, 2020 at 11:30 AM Krabina Bernhard <[hidden email]> wrote:
>
>> 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":
>> "[&quot;twitter&quot;,&quot;facebook&quot;,&quot;pinterest&quot;]",
>> "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?
>>
>>
>> so long,
>> Bernhard
>>
>> _______________________________________________
>> Wikitech-l mailing list
>> [hidden email]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l