mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 17:59:29 +02:00
Merge branch 'release-5.0.5'
This commit is contained in:
8
NEWS
8
NEWS
@ -1,3 +1,11 @@
|
|||||||
|
Version 5.0.5 (2017-10-17)
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
- Fix: Avoid errors with SQLite database.
|
||||||
|
|
||||||
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
|
||||||
|
|
||||||
Version 5.0.4 (2017-09-23)
|
Version 5.0.4 (2017-09-23)
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
],
|
],
|
||||||
"type": "parserhook",
|
"type": "parserhook",
|
||||||
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
|
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
|
||||||
"version": "5.0.4",
|
"version": "5.0.5",
|
||||||
"license-name": "GPL-2.0+",
|
"license-name": "GPL-2.0+",
|
||||||
"descriptionmsg": "linktitles-desc",
|
"descriptionmsg": "linktitles-desc",
|
||||||
"requires": {
|
"requires": {
|
||||||
|
2
gh-pages
2
gh-pages
Submodule gh-pages updated: 570fcaa3c5...7161033535
@ -169,9 +169,24 @@ class Config {
|
|||||||
*/
|
*/
|
||||||
public $sameNamespace;
|
public $sameNamespace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caches the global $wgDBtype variable.
|
||||||
|
* @var string $dbType;
|
||||||
|
*/
|
||||||
|
private $dbType;
|
||||||
|
|
||||||
public $enableConsoleOutput;
|
public $enableConsoleOutput;
|
||||||
public $enableDebugConsoleOutput;
|
public $enableDebugConsoleOutput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the MediaWiki database is SQLITE by inspecting the
|
||||||
|
* $wgDBtype variable (which is cached in $this->dbType).
|
||||||
|
* @return bool True if the database is SQLITE.
|
||||||
|
*/
|
||||||
|
public function sqliteDatabase() {
|
||||||
|
return $this->dbType === 'sqlite';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new Config object.
|
* Constructs a new Config object.
|
||||||
*
|
*
|
||||||
@ -197,6 +212,7 @@ class Config {
|
|||||||
global $wgLinkTitlesEnableNoTargetMagicWord;
|
global $wgLinkTitlesEnableNoTargetMagicWord;
|
||||||
global $wgLinkTitlesCheckRedirect;
|
global $wgLinkTitlesCheckRedirect;
|
||||||
global $wgLinkTitlesSpecialPageReloadAfter;
|
global $wgLinkTitlesSpecialPageReloadAfter;
|
||||||
|
global $wgDBtype;
|
||||||
$this->parseOnEdit = $wgLinkTitlesParseOnEdit;
|
$this->parseOnEdit = $wgLinkTitlesParseOnEdit;
|
||||||
$this->parseOnRender = $wgLinkTitlesParseOnRender;
|
$this->parseOnRender = $wgLinkTitlesParseOnRender;
|
||||||
$this->preferShortTitles = $wgLinkTitlesPreferShortTitles;
|
$this->preferShortTitles = $wgLinkTitlesPreferShortTitles;
|
||||||
@ -217,5 +233,6 @@ class Config {
|
|||||||
$this->specialPageReloadAfter = $wgLinkTitlesSpecialPageReloadAfter;
|
$this->specialPageReloadAfter = $wgLinkTitlesSpecialPageReloadAfter;
|
||||||
$this->enableConsoleOutput = false;
|
$this->enableConsoleOutput = false;
|
||||||
$this->enableDebugConsoleOutput = false;
|
$this->enableDebugConsoleOutput = false;
|
||||||
|
$this->dbType = $wgDBtype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,12 @@ class Targets {
|
|||||||
|
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the CHAR_LENGTH function to be used with the database connection.
|
||||||
|
* @var string $charLengthFunction
|
||||||
|
*/
|
||||||
|
private $charLengthFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor is private to enforce using the singleton pattern.
|
* The constructor is private to enforce using the singleton pattern.
|
||||||
* @param \Title $title
|
* @param \Title $title
|
||||||
@ -129,34 +135,25 @@ class Targets {
|
|||||||
// = 0) are returned. Since the db may be sqlite, we need a try..catch
|
// = 0) are returned. Since the db may be sqlite, we need a try..catch
|
||||||
// structure because sqlite does not support the CHAR_LENGTH function.
|
// structure because sqlite does not support the CHAR_LENGTH function.
|
||||||
$dbr = wfGetDB( DB_SLAVE );
|
$dbr = wfGetDB( DB_SLAVE );
|
||||||
try {
|
$this->queryResult = $dbr->select(
|
||||||
$this->queryResult = $dbr->select(
|
'page',
|
||||||
'page',
|
array( 'page_title', 'page_namespace' , "weight" => $weightSelect),
|
||||||
array( 'page_title', 'page_namespace' , "weight" => $weightSelect),
|
array_filter(
|
||||||
array_filter(
|
array(
|
||||||
array(
|
'page_namespace IN ' . $namespacesClause,
|
||||||
'page_namespace IN ' . $namespacesClause,
|
$this->charLength() . '(page_title) >= ' . $this->config->minimumTitleLength,
|
||||||
'CHAR_LENGTH(page_title) >= ' . $this->config->minimumTitleLength,
|
$blackList,
|
||||||
$blackList,
|
)
|
||||||
)
|
),
|
||||||
),
|
__METHOD__,
|
||||||
__METHOD__,
|
array( 'ORDER BY' => 'weight ASC, ' . $this->charLength() . '(page_title) ' . $sortOrder )
|
||||||
array( 'ORDER BY' => 'weight ASC, CHAR_LENGTH(page_title) ' . $sortOrder )
|
);
|
||||||
);
|
}
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->queryResult = $dbr->select(
|
private function charLength() {
|
||||||
'page',
|
if ($this->charLengthFunction === null) {
|
||||||
array( 'page_title', 'page_namespace' , "weight" => $weightSelect ),
|
$this->charLengthFunction = $this->config->sqliteDatabase() ? 'LENGTH' : 'CHAR_LENGTH';
|
||||||
array_filter(
|
|
||||||
array(
|
|
||||||
'page_namespace IN ' . $namespacesClause,
|
|
||||||
'LENGTH(page_title) >= ' . $this->config->minimumTitleLength,
|
|
||||||
$blackList,
|
|
||||||
)
|
|
||||||
),
|
|
||||||
__METHOD__,
|
|
||||||
array( 'ORDER BY' => 'weight ASC, LENGTH(page_title) ' . $sortOrder )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
return $this->charLengthFunction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user