Merge branch 'release-4.0.4'

This commit is contained in:
Daniel Kraus
2016-11-30 06:11:38 +01:00
3 changed files with 15 additions and 4 deletions

8
NEWS
View File

@ -1,3 +1,11 @@
Version 4.0.4 (2016-11-30)
------------------------------------------------------------------------
- Fix: Do not link titles twice if $wgLinkTitlesFirstOnly and $wgLinkTitlesSmartMode are both true.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.3 (2016-11-22) Version 4.0.3 (2016-11-22)
------------------------------------------------------------------------ ------------------------------------------------------------------------

View File

@ -6,7 +6,7 @@
], ],
"type": "parserhook", "type": "parserhook",
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles", "url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
"version": "4.0.3", "version": "4.0.4",
"license-name": "GPL-2.0+", "license-name": "GPL-2.0+",
"descriptionmsg": "linktitles-desc", "descriptionmsg": "linktitles-desc",
"requires": { "requires": {

View File

@ -123,6 +123,8 @@ class Extension {
( $wgLinkTitlesPreferShortTitles ) ? $sort_order = 'ASC' : $sort_order = 'DESC'; ( $wgLinkTitlesPreferShortTitles ) ? $sort_order = 'ASC' : $sort_order = 'DESC';
( $wgLinkTitlesFirstOnly ) ? $limit = 1 : $limit = -1; ( $wgLinkTitlesFirstOnly ) ? $limit = 1 : $limit = -1;
$limitReached = false;
error_log($wgLinkTitlesFirstOnly);
self::$currentTitle = $title; self::$currentTitle = $title;
$newText = $text; $newText = $text;
@ -214,7 +216,8 @@ class Extension {
// even indexes will point to text that is not enclosed by brackets // even indexes will point to text that is not enclosed by brackets
$arr[$i] = preg_replace_callback( $regex, $arr[$i] = preg_replace_callback( $regex,
'LinkTitles\Extension::simpleModeCallback', $arr[$i], $limit, $count ); 'LinkTitles\Extension::simpleModeCallback', $arr[$i], $limit, $count );
if (( $limit >= 0 ) && ( $count > 0 )) { if ( $wgLinkTitlesFirstOnly && ( $count > 0 ) ) {
$limitReached = true;
break; break;
}; };
}; };
@ -223,7 +226,7 @@ class Extension {
// If smart mode is turned on, the extension will perform a second // If smart mode is turned on, the extension will perform a second
// pass on the page and add links with aliases where the case does // pass on the page and add links with aliases where the case does
// not match. // not match.
if ($wgLinkTitlesSmartMode) { if ( $wgLinkTitlesSmartMode && !$limitReached ) {
$arr = preg_split( self::$delimiter, $newText, -1, PREG_SPLIT_DELIM_CAPTURE ); $arr = preg_split( self::$delimiter, $newText, -1, PREG_SPLIT_DELIM_CAPTURE );
for ( $i = 0; $i < count( $arr ); $i+=2 ) { for ( $i = 0; $i < count( $arr ); $i+=2 ) {
@ -232,7 +235,7 @@ class Extension {
self::$wordStartDelim . '(' . $quotedTitle . ')' . self::$wordStartDelim . '(' . $quotedTitle . ')' .
self::$wordEndDelim . '/iS', 'LinkTitles\Extension::smartModeCallback', self::$wordEndDelim . '/iS', 'LinkTitles\Extension::smartModeCallback',
$arr[$i], $limit, $count ); $arr[$i], $limit, $count );
if (( $limit >= 0 ) && ( $count > 0 )) { if ( $wgLinkTitlesFirstOnly && ( $count > 0 )) {
break; break;
}; };
}; };