Use ExtensionRegistry instead of class name
authorWMDE-Fisch <christoph.jauera@wikimedia.de>
Wed, 14 Aug 2019 17:07:39 +0000 (19:07 +0200)
committerWMDE-Fisch <christoph.jauera@wikimedia.de>
Wed, 14 Aug 2019 17:07:39 +0000 (19:07 +0200)
Use the ExtensionRegistry instead of checking for the main class
name of the Cite extension. - I'm not entirely sure if this is much
better. A hook would still be the better option. But at least Cite
could be refactored and the class name changed.

Bug: T89151
Change-Id: I35e5aa9955141b575de68a5be2c0d5b87585eb77

includes/search/SearchHighlighter.php

index 2579942..8f0db44 100644 (file)
@@ -74,8 +74,8 @@ class SearchHighlighter {
                        3 => "/(\n\\{\\|)|(\n\\|\\})/" ]; // table
 
                // @todo FIXME: This should prolly be a hook or something
                        3 => "/(\n\\{\\|)|(\n\\|\\})/" ]; // table
 
                // @todo FIXME: This should prolly be a hook or something
-               // instead of hardcoding a class name from the Cite extension
-               if ( class_exists( 'Cite' ) ) {
+               // instead of hardcoding the name of the Cite extension
+               if ( \ExtensionRegistry::getInstance()->isLoaded( 'Cite' ) ) {
                        $spat .= '|(<ref>)'; // references via cite extension
                        $endPatterns[4] = '/(<ref>)|(<\/ref>)/';
                }
                        $spat .= '|(<ref>)'; // references via cite extension
                        $endPatterns[4] = '/(<ref>)|(<\/ref>)/';
                }