Fix bug that could prevent linking when $wgLinkTitlesFirstOnly was set to true.

This commit is contained in:
Daniel Kraus
2012-12-31 12:47:22 +01:00
parent 5f82daad6a
commit 77c5840199
4 changed files with 10 additions and 4 deletions

View File

@ -144,12 +144,14 @@
$arr = preg_split( $delimiter, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
// dump( $arr );
$safeTitle = str_replace( '/', '\/', $title );
( $wgLinkTitlesFirstOnly ) ? $loopLimit = 1 : $loopLimit = count( $arr );
for ( $i = 0; $i < $loopLimit; $i+=2 ) {
for ( $i = 0; $i < count( $arr ); $i+=2 ) {
// even indexes will point to text that is not enclosed by brackets
$arr[$i] = preg_replace( '/(?<![\:\.\@\/\?\&])' .
$wordStartDelim . '(' . $safeTitle . ')' .
$wordEndDelim . '/i', '[[$1]]', $arr[$i], $limit );
$wordEndDelim . '/i', '[[$1]]', $arr[$i], $limit, $count );
if (( $limit >= 0 ) && ( $count > 0 )) {
break;
};
};
$text = implode( '', $arr );
}; // if $title != $myTitle

View File

@ -48,7 +48,7 @@
'name' => 'LinkTitles',
'author' => '[http://www.mediawiki.org/wiki/User:Bovender Daniel Kraus]',
'url' => 'http://www.mediawiki.org/wiki/Extension:LinkTitles',
'version' => '1.6.0',
'version' => '1.6.1',
'descriptionmsg' => 'linktitles-desc'
);

4
NEWS
View File

@ -1,3 +1,7 @@
LinkTitles 1.6.1: 2012-12-31
* Fixed a bug that caused linking to fail in certain situations when
$wgLinkTitlesFirstOnly was set to true.
LinkTitles 1.6.0: 2012-12-22
* Added new options to restrict linking to page titles at the beginning or an
end of a word. This enables linking variants of a page title.

Binary file not shown.