Page MenuHomePhabricator

Loading both Lingo and SemanticGlossary with wfLoadExtension throws an exception
Closed, DeclinedPublic

Description

I have installed Lingo and Semantic Glossary using composer under MediaWiki 1.26:

composer require mediawiki/lingo "~2.0"
composer require mediawiki/semantic-glossary "~2.0"

If I follow the installation instructions and add the two extension registration statements

wfLoadExtension( "Lingo" );
wfLoadExtension( "SemanticGlossary" );

an exception is raised in mediawiki/includes/MagicWords.php:

[error] [fd810cd6] /mywiki/index.php/Main_Page   ErrorException from line 951 of .../includes/MagicWord.php: PHP Warning: preg_match_all(): Compilation failed: two named subpatterns have the same name at offset 340

I added some debugging statements and determined that the subpattern name that is duplicated is <a_noglossary>:

regex = /(?P<a_notoc>__NOTOC__)|(?P<a_nogallery>__NOGALLERY__)|(?P<a_forcetoc>__FORCETOC__)|(?P<a_toc>__TOC__)|(?P<a_noeditsection>__NOEDITSECTION__)|(?P<a_notitleconvert>__NOTITLECONVERT__)|(?P<b_notitleconvert>__NOTC__)|(?P<a_nocontentconvert>__NOCONTENTCONVERT__)|(?P<b_nocontentconvert>__NOCC__)|(?P<a_noglossary>__NOGLOSSARY__)|(?P<a_noglossary>__NOGLOSSARY__)/iuS

If I remove the extension registration statement for Lingo, Lingo is still loaded, and the exception does not get thrown. The fact that SemanticGlossary loads Lingo is discussed at [0].

Is the fact that Lingo should not be explicitly loaded an omission in the SemanticGlossary documentation? Or should the duplicate definition of the NOGLOSSARY magic word if Lingo and SemanticGlossary are both explicitly loaded be considered a bug? Should/can SemanticGlossary check to see if Lingo is already loaded before it loads it? Or is the $registry->load() code supposed to take care of making sure that an extension is not loaded twice?

[0] https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/1367#issuecomment-194778425

Event Timeline

Is the fact that Lingo should not be explicitly loaded an omission in the SemanticGlossary documentation? Or should the duplicate definition of the NOGLOSSARY magic word if Lingo and SemanticGlossary are both explicitly loaded be considered a bug? Should/can SemanticGlossary check to see if Lingo is already loaded before it loads it? Or is the $registry->load() code supposed to take care of making sure that an extension is not loaded twice?

Maybe. As the SG install instructions do not ask the user to install Lingo, I did not expect that anybody would do that.
No.
Probably.
I don't know, if it is supposed to, but it does not.

SemanticGlossary issues are tracked at https://github.com/SemanticMediaWiki/SemanticGlossary/issues hence closing this task as declined here. (Feel free to reopen and adjust the associated project tags if this is about Cargo though.)