Merge branch 'release-4.1.0'

This commit is contained in:
Daniel Kraus
2017-08-25 19:31:40 +02:00
5 changed files with 81 additions and 43 deletions

32
NEWS
View File

@ -1,9 +1,19 @@
Version 7.1.0 (2017-08-24)
------------------------------------------------------------------------
- New: Mark sections that are not to be automatically linked with the new `<noautolinks>..</noautolinks>` tag.
- New: Mark sections that are to be automatically linked with the new `<autolinks>..</autolinks>` tag. This tag only makes sense on pages with the `__NOAUTOLINKS__` magic word, or if both `$wgLinkTitlesParseOnEdit` and `$wgLinkTitlesParseOnRender` are set to false. Note that this tag is parsed when a page is rendered, not when it is saved. Therefore, the links will not appear in the page source.
- Fix: Properly handle templates that include other templates.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.9 (2017-03-21) Version 4.0.9 (2017-03-21)
------------------------------------------------------------------------ ------------------------------------------------------------------------
- Fix: __NOAUTOLINKS__ was not respected during rendering. - Fix: __NOAUTOLINKS__ was not respected during rendering.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.8 (2017-02-16) Version 4.0.8 (2017-02-16)
@ -13,7 +23,7 @@ Version 4.0.8 (2017-02-16)
- Fix: The special page and the maintenance script did not work in MW 1.28. - Fix: The special page and the maintenance script did not work in MW 1.28.
- Fix: The special page did not work. - Fix: The special page did not work.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.7 (2017-01-02) Version 4.0.7 (2017-01-02)
@ -21,7 +31,7 @@ Version 4.0.7 (2017-01-02)
- Improvement: Increase performance of special page and maintenance script. - Improvement: Increase performance of special page and maintenance script.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.6 (2016-12-28) Version 4.0.6 (2016-12-28)
@ -30,7 +40,7 @@ Version 4.0.6 (2016-12-28)
- Fix: Bug fixes. - Fix: Bug fixes.
- Fix: Custom namespace weights were not respected. - Fix: Custom namespace weights were not respected.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.5 (2016-12-14) Version 4.0.5 (2016-12-14)
@ -40,7 +50,7 @@ Version 4.0.5 (2016-12-14)
- Fix: Remove leftover error log call. - Fix: Remove leftover error log call.
- Improvement: Refactored maintenance script, improving user interaction. - Improvement: Refactored maintenance script, improving user interaction.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.4 (2016-11-30) Version 4.0.4 (2016-11-30)
@ -48,7 +58,7 @@ Version 4.0.4 (2016-11-30)
- Fix: Do not link titles twice if $wgLinkTitlesFirstOnly and $wgLinkTitlesSmartMode are both true. - 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)
@ -56,7 +66,7 @@ Version 4.0.3 (2016-11-22)
- Fix: __NOAUTOLINKS__ magic word would not be respected when saving an edited page. - Fix: __NOAUTOLINKS__ magic word would not be respected when saving an edited page.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.2 (2016-11-09) Version 4.0.2 (2016-11-09)
@ -65,7 +75,7 @@ Version 4.0.2 (2016-11-09)
- FIX: Removed a fatal bug in the LinkTitles_Maintenance script. - FIX: Removed a fatal bug in the LinkTitles_Maintenance script.
- FIX: Repaired severely broken namespaces support. - FIX: Repaired severely broken namespaces support.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.1 (2016-11-08) Version 4.0.1 (2016-11-08)
@ -73,7 +83,7 @@ Version 4.0.1 (2016-11-08)
- FIX: Prevent syntax error when accessing special page. - FIX: Prevent syntax error when accessing special page.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 4.0.0 (2016-11-05) Version 4.0.0 (2016-11-05)
@ -85,7 +95,7 @@ Version 4.0.0 (2016-11-05)
- NEW: Support namespaces. - NEW: Support namespaces.
- NEW: Use the new extension format introduced by MediaWiki 1.25; the extension will no longer run with older MediaWiki versions. - NEW: Use the new extension format introduced by MediaWiki 1.25; the extension will no longer run with older MediaWiki versions.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Version 3.1.0. (2015-02-05) Version 3.1.0. (2015-02-05)
@ -93,7 +103,7 @@ Version 3.1.0. (2015-02-05)
- IMPROVEMENT: Do not link inside <file>...</file> tags. - IMPROVEMENT: Do not link inside <file>...</file> tags.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

View File

@ -17,11 +17,14 @@ This extension is [semantically versioned](http://semver.org).
Contributing Contributing
------------ ------------
If you wish to contribute, please issue pull requests against the `develop` If you wish to contribute, please issue pull requests against the `develop`
branch, as I follow Vincent Driessen's advice on [A successful Git branching branch, as I follow Vincent Driessen's advice on [A successful Git branching
model](http://nvie.com/git-model) (knowing that there are [alternative model](http://nvie.com/git-model) (knowing that there are [alternative
workflows](http://scottchacon.com/2011/08/31/github-flow.html)). workflows](http://scottchacon.com/2011/08/31/github-flow.html)).
The `master` branch contains stable releases only, so it is safe to pull the
master branch if you want to install the extension for your own wiki.
Contributors Contributors
------------ ------------

View File

@ -7,7 +7,7 @@
], ],
"type": "parserhook", "type": "parserhook",
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles", "url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
"version": "4.0.9", "version": "4.1.0",
"license-name": "GPL-2.0+", "license-name": "GPL-2.0+",
"descriptionmsg": "linktitles-desc", "descriptionmsg": "linktitles-desc",
"requires": { "requires": {
@ -56,6 +56,9 @@
], ],
"GetDoubleUnderscoreIDs": [ "GetDoubleUnderscoreIDs": [
"LinkTitles\\Extension::onGetDoubleUnderscoreIDs" "LinkTitles\\Extension::onGetDoubleUnderscoreIDs"
],
"ParserFirstCallInit": [
"LinkTitles\\Extension::onParserFirstCallInit"
] ]
}, },
"callback": "LinkTitles\\Extension::setup", "callback": "LinkTitles\\Extension::setup",

View File

@ -45,8 +45,8 @@ class Extension {
/// A Title object for the target page currently being examined. /// A Title object for the target page currently being examined.
private static $targetTitle; private static $targetTitle;
// The TitleValue object of the target page // The TitleValue object of the target page
private static $targetTitleValue; private static $targetTitleValue;
/// The content object for the currently processed target page. /// The content object for the currently processed target page.
/// This variable is necessary to be able to prevent loading the target /// This variable is necessary to be able to prevent loading the target
@ -153,10 +153,10 @@ class Extension {
// Escape certain special characters in the page title to prevent // Escape certain special characters in the page title to prevent
// regexp compilation errors // regexp compilation errors
self::$targetTitleText = self::$targetTitle->getText(); self::$targetTitleText = self::$targetTitle->getText();
$quotedTitle = preg_quote(self::$targetTitleText, '/'); $quotedTitle = preg_quote( self::$targetTitleText, '/' );
self::ltDebugLog('TargetTitle='. self::$targetTitleText,"private"); self::ltDebugLog( 'TargetTitle='. self::$targetTitleText, 'private' );
self::ltDebugLog('TargetTitleQuoted='. $quotedTitle,"private"); self::ltDebugLog( 'TargetTitleQuoted='. $quotedTitle, 'private' );
// Depending on the global configuration setting $wgCapitalLinks, // Depending on the global configuration setting $wgCapitalLinks,
// the title has to be searched for either in a strictly case-sensitive // the title has to be searched for either in a strictly case-sensitive
@ -247,6 +247,27 @@ class Extension {
return true; return true;
} }
public static function onParserFirstCallInit( \Parser $parser ) {
$parser->setHook( 'noautolinks', 'LinkTitles\Extension::doNoautolinksTag' );
$parser->setHook( 'autolinks', 'LinkTitles\Extension::doAutolinksTag' );
}
/// Removes the extra tag that this extension provides (<noautolinks>)
/// by simply returning the text between the tags (if any).
/// See https://www.mediawiki.org/wiki/Manual:Tag_extensions#Example
public static function doNoautolinksTag( $input, array $args, \Parser $parser, \PPFrame $frame ) {
return htmlspecialchars( $input );
}
/// Removes the extra tag that this extension provides (<noautolinks>)
/// by simply returning the text between the tags (if any).
/// See https://www.mediawiki.org/wiki/Manual:Tag_extensions#How_do_I_render_wikitext_in_my_extension.3F
public static function doAutolinksTag( $input, array $args, \Parser $parser, \PPFrame $frame ) {
$withLinks = self::parseContent( $parser->getTitle(), $input );
$output = $parser->recursiveTagParse( $withLinks, $frame );
return $output;
}
// Fetches the page titles from the database. // Fetches the page titles from the database.
// @param $currentNamespace String holding the namespace of the page currently being processed. // @param $currentNamespace String holding the namespace of the page currently being processed.
private static function fetchPageTitles( $currentNamespace ) { private static function fetchPageTitles( $currentNamespace ) {
@ -424,10 +445,10 @@ class Extension {
return true; return true;
} }
/// Builds the delimiter that is used in a regexp to separate /// Builds the delimiter that is used in a regexp to separate
/// text that should be parsed from text that should not be /// text that should be parsed from text that should not be
/// parsed (e.g. inside existing links etc.) /// parsed (e.g. inside existing links etc.)
private static function BuildDelimiters() { private static function BuildDelimiters() {
// Configuration variables need to be defined here as globals. // Configuration variables need to be defined here as globals.
global $wgLinkTitlesParseHeadings; global $wgLinkTitlesParseHeadings;
global $wgLinkTitlesSkipTemplates; global $wgLinkTitlesSkipTemplates;
@ -443,7 +464,9 @@ private static function BuildDelimiters() {
if ( $wgLinkTitlesSkipTemplates ) if ( $wgLinkTitlesSkipTemplates )
{ {
$templatesDelimiter = '{{[^}]+}}|'; // Use recursive regex to balance curly braces;
// see http://www.regular-expressions.info/recurse.html
$templatesDelimiter = '{{(?>[^{}]|(?R))*}}|';
} else { } else {
// Match template names (ignoring any piped [[]] links in them) // Match template names (ignoring any piped [[]] links in them)
// along with the trailing pipe and parameter name or closing // along with the trailing pipe and parameter name or closing
@ -478,28 +501,27 @@ private static function BuildDelimiters() {
'<span.+?>|<\/span>|' . // attributes of span elements '<span.+?>|<\/span>|' . // attributes of span elements
'<file>[^<]*<\/file>|' . // stuff inside file elements '<file>[^<]*<\/file>|' . // stuff inside file elements
'style=".+?"|class=".+?"|' . // styles and classes (e.g. of wikitables) 'style=".+?"|class=".+?"|' . // styles and classes (e.g. of wikitables)
'<noautolinks>.*?<\/noautolinks>|' . // custom tag 'noautolinks'
'\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|' . // urls '\[' . $urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|' . // urls
'(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' . // email addresses '(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b)' . // email addresses
')/ismS'; ')/ismS';
}
/// Local Debugging output function which can send output to console as well
public static function ltDebugLog($text) {
if ( self::$ltConsoleOutputDebug ) {
print $text . "\n";
} }
wfDebugLog( 'LinkTitles', $text , 'private' );
}
/// Local Debugging output function which can send output to console as well /// Local Logging output function which can send output to console as well
public static function ltDebugLog($text) { public static function ltLog($text) {
if (self::$ltConsoleOutputDebug) if (self::$ltConsoleOutput) {
{ print $text . "\n";
print $text . "\n"; }
} wfDebugLog( 'LinkTitles', $text , 'private' );
wfDebugLog('LinkTitles', $text , 'private'); }
}
/// Local Logging output function which can send output to console as well
public static function ltLog($text) {
if (self::$ltConsoleOutput)
{
print $text . "\n";
}
wfDebugLog('LinkTitles', $text , 'private');
}
} }
// vim: ts=2:sw=2:noet:comments^=\:/// // vim: ts=2:sw=2:noet:comments^=\:///