From 610c221211ebc3134e234a51901387f67003f820 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Mon, 2 Jan 2017 13:42:34 +0100 Subject: [PATCH] Fix preventing linking to self. --- includes/LinkTitles_Extension.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/LinkTitles_Extension.php b/includes/LinkTitles_Extension.php index 77de25e..b95c77b 100644 --- a/includes/LinkTitles_Extension.php +++ b/includes/LinkTitles_Extension.php @@ -141,6 +141,9 @@ class Extension { foreach( self::$pageTitles as $row ) { self::newTarget( $row->page_namespace, $row->page_title ); + // Don't link current page + if ( self::$targetTitle->equals( self::$currentTitle ) ) { continue; } + // split the page content by [[...]] groups // credits to inhan @ StackOverflow for suggesting preg_split // see http://stackoverflow.com/questions/10672286 @@ -253,9 +256,7 @@ class Extension { ( $wgLinkTitlesPreferShortTitles ) ? $sort_order = 'ASC' : $sort_order = 'DESC'; // Build a blacklist of pages that are not supposed to be link // targets. This includes the current page. - $blackList = str_replace( ' ', '_', - '("' . implode( '","',$wgLinkTitlesBlackList ) . '","' . - addslashes( self::$currentTitle->getDbKey() ) . '")' ); + $blackList = str_replace( ' ', '_', '("' . implode( '","',$wgLinkTitlesBlackList ) . '")' ); // Build our weight list. Make sure current namespace is first element $namespaces = array_diff( $wgLinkTitlesNamespaces, [ $currentNamespace ] );