From eef4e793e73b428402176c1b7cc73c55e1efd683 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Tue, 10 Jun 2014 19:04:27 +0200 Subject: [PATCH] Use GetDoubleUnderscoreIDs hook to remove magic words. Prevously, the magic words were removed by hooking onto ParserBeforeTidy. Since the Parser class provides its own mechanism for removing magic words that are surrounded by double underscores, we now use this (undocumented) hook. --- LinkTitles.body.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/LinkTitles.body.php b/LinkTitles.body.php index b905f63..82c5f1b 100755 --- a/LinkTitles.body.php +++ b/LinkTitles.body.php @@ -56,7 +56,7 @@ $wgHooks['ArticleAfterFetchContentObject'][] = 'LinkTitles::onArticleAfterFetchContentObject'; }; - $wgHooks['ParserBeforeTidy'][] = 'LinkTitles::removeMagicWord'; + $wgHooks['GetDoubleUnderscoreIDs'][] = 'LinkTitles::onGetDoubleUnderscoreIDs'; } /// Event handler that is hooked to the ArticleSave event. @@ -269,18 +269,14 @@ ); } - /// Remove the magic words that this extension introduces from the - /// $text, so that they do not appear on the rendered page. - /// @param $parser Parser object - /// @param $text String that contains the page content. + /// Adds the two magic words defined by this extension to the list of + /// 'double-underscore' terms that are automatically removed before a + /// page is displayed. + /// @param $doubleUnderscoreIDs Array of magic word IDs. /// @returns true - static function removeMagicWord( &$parser, &$text ) { - $mwa = new MagicWordArray(array( - 'MAG_LINKTITLES_NOAUTOLINKS', - 'MAG_LINKTITLES_NOTARGET' - ) - ); - $mwa->matchAndRemove( $text ); + public static function onGetDoubleUnderscoreIDs( &$doubleUnderscoreIDs ) { + $doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOTARGET'; + $doubleUnderscoreIDs[] = 'MAG_LINKTITLES_NOAUTOLINKS'; return true; }