Skip to content

Commit

Permalink
Merge branch 'release-4.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
bovender committed Dec 28, 2016
2 parents deef389 + 20937c2 commit bfee9b9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 4.0.6 (2016-12-28)
------------------------------------------------------------------------

- Fix: Custom namespace weights were not respected.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


Version 4.0.5 (2016-12-14)
------------------------------------------------------------------------

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ pages](http://bovender.github.io/LinkTitles).

This extension is [semantically versioned](http://semver.org).

If you wish to contribute, please issue pull requests against the `develop` branch.

Contributing
------------

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
model](http://nvie.com/git-model) (knowing that there are [alternative
workflows](http://scottchacon.com/2011/08/31/github-flow.html)).


Contributors
------------

- Daniel Kraus (@bovender), main developer
- Ulrich Strauss (@c0nnex), namespaces
- Brent Laabs (@labster), bug fixes
5 changes: 3 additions & 2 deletions extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
"name": "LinkTitles",
"author": [
"[https://www.mediawiki.org/wiki/User:Bovender Daniel Kraus (bovender)]",
"Ulrich Strauss (c0nnex)"
"Ulrich Strauss (c0nnex)",
"Brent Laabs (labster)"
],
"type": "parserhook",
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
"version": "4.0.5",
"version": "4.0.6",
"license-name": "GPL-2.0+",
"descriptionmsg": "linktitles-desc",
"requires": {
Expand Down
30 changes: 15 additions & 15 deletions includes/LinkTitles_Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Extension {

/// A Title object for the target page currently being examined.
private static $targetTitle;

// The TitleValue object of the target page
private static $targetTitleValue;

Expand All @@ -55,7 +55,7 @@ class Extension {

private static $wordStartDelim;
private static $wordEndDelim;

public static $ltConsoleOutput;
public static $ltConsoleOutputDebug;

Expand Down Expand Up @@ -130,16 +130,16 @@ private static function parseContent( $title, &$text ) {

// Build a blacklist of pages that are not supposed to be link
// targets. This includes the current page.
$blackList = str_replace( '_', ' ',
'("' . implode( '", "',$wgLinkTitlesBlackList ) . '", "' .
$blackList = str_replace( ' ', '_',
'("' . implode( '","',$wgLinkTitlesBlackList ) . '","' .
addslashes( self::$currentTitle->getDbKey() ) . '")' );

$currentNamespace[] = $title->getNamespace();

// Build our weight list. Make sure current namespace is first element
$namespaces = array_diff($wgLinkTitlesNamespaces, $currentNamespace);
array_unshift($namespaces, $currentNamespace[0] );

// No need for sanitiy check. we are sure that we have at least one element in the array
$weightSelect = "CASE page_namespace ";
$currentWeight = 0;
Expand All @@ -148,7 +148,7 @@ private static function parseContent( $title, &$text ) {
$weightSelect = $weightSelect . " WHEN " . $namspacevalue . " THEN " . $currentWeight . PHP_EOL;
}
$weightSelect = $weightSelect . " END ";
$namespacesClause = str_replace( '_', ' ','(' . implode( ', ',$namespaces ) . ')' );
$namespacesClause = '(' . implode( ', ', $namespaces ) . ')';

// Build an SQL query and fetch all page titles ordered by length from
// shortest to longest. Only titles from 'normal' pages (namespace uid
Expand All @@ -165,7 +165,7 @@ private static function parseContent( $title, &$text ) {
'page_title NOT IN ' . $blackList,
),
__METHOD__,
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order )
array( 'ORDER BY' => 'weight ASC, CHAR_LENGTH(page_title) ' . $sort_order )
);
} catch (Exception $e) {
$res = $dbr->select(
Expand All @@ -177,7 +177,7 @@ private static function parseContent( $title, &$text ) {
'page_title NOT IN ' . $blackList,
),
__METHOD__,
array( 'ORDER BY' => 'LENGTH(page_title) ' . $sort_order )
array( 'ORDER BY' => 'weight ASC, LENGTH(page_title) ' . $sort_order )
);
}

Expand All @@ -194,7 +194,7 @@ private static function parseContent( $title, &$text ) {
// regexp compilation errors
self::$targetTitleText = self::$targetTitle->getText();
$quotedTitle = preg_quote(self::$targetTitleText, '/');

self::ltDebugLog('TargetTitle='. self::$targetTitleText,"private");
self::ltDebugLog('TargetTitleQuoted='. $quotedTitle,"private");

Expand Down Expand Up @@ -243,7 +243,7 @@ private static function parseContent( $title, &$text ) {
}; // foreach $res as $row
return $newText;
}

/// Automatically processes a single page, given a $title Title object.
/// This function is called by the SpecialLinkTitles class and the
/// LinkTitlesJob class.
Expand Down Expand Up @@ -349,9 +349,9 @@ private static function smartModeCallback( array $matches ) {

/// Sets member variables for the current target page.
private static function newTarget( $ns, $title ) {
self::$targetTitle = \Title::makeTitleSafe( $ns, $title );
self::ltDebugLog( 'newtarget='. self::$targetTitle->getText(), "private" );
self::$targetTitleValue = self::$targetTitle->getTitleValue();
self::$targetTitle = \Title::makeTitleSafe( $ns, $title );
self::ltDebugLog( 'newtarget='. self::$targetTitle->getText(), "private" );
self::$targetTitleValue = self::$targetTitle->getTitleValue();
self::ltDebugLog( 'altTarget='. self::$targetTitleValue->getText(), "private" );
self::$targetContent = null;
}
Expand Down Expand Up @@ -477,6 +477,6 @@ public static function ltLog($text) {
}
wfDebugLog('LinkTitles', $text , 'private');
}
}
}

// vim: ts=2:sw=2:noet:comments^=\:///

0 comments on commit bfee9b9

Please sign in to comment.