SemanticMediaWiki / SemanticGlossary

Allows you define terms and abbreviations together with a definition.
https://www.mediawiki.org/wiki/Extension:Semantic_Glossary
Other
12 stars 11 forks source link

Load Lingo only when not already loaded? #43

Closed hermannschwaerzlerUIBK closed 5 years ago

hermannschwaerzlerUIBK commented 5 years ago

Setup and configuration

As Lingo is already installed and loaded in BlueSpice and I did not want to change the general configuration of the wiki I was looking for a way to avoid loading Lingo inside SemanticGlossary::initExtension.

I came up with this:

--- /tmp/SemanticGlossary.php   2019-01-08 15:15:52.885638016 +0100
+++ SemanticGlossary.php        2019-01-08 15:14:50.671966229 +0100
@@ -21,10 +21,13 @@

                // must NOT use ExtensionRegistry::getInstance() to avoid recursion!
                $registry = new ExtensionRegistry();
-               if ( file_exists( __DIR__ . '/extensions/Lingo/extension.json' ) ) {
-                       $registry->load( __DIR__ . '/extensions/Lingo/extension.json' );
-               } else {
-                       $registry->load( $GLOBALS[ 'wgExtensionDirectory' ] . '/Lingo/extension.json' );
+
+               if ( ! class_exists( 'Lingo\Lingo' ) ) {
+                       if ( file_exists( __DIR__ . '/extensions/Lingo/extension.json' ) ) {
+                               $registry->load( __DIR__ . '/extensions/Lingo/extension.json' );
+                       } else {
+                               $registry->load( $GLOBALS[ 'wgExtensionDirectory' ] . '/Lingo/extension.json' );
+                       }
                }

                $GLOBALS[ 'wgexLingoBackend' ] = 'SG\LingoBackendAdapter';

What do you think? Is there a better way? Shall I create a pull request?

kghbln commented 5 years ago

Thanks a lot for posting this issue and suggesting a solution.

@s7eph4n I am not sure if you get notifications about issues.

s7eph4n commented 5 years ago

Lingo already being loaded is of course totally against the installation procedure. :smiley: A pull request would be great!