Make the SQL query work with sqlite databases.

The fallback query does not use the CHAR_LENGTH function, but uses LENGTH.
This commit is contained in:
Daniel Kraus
2013-07-22 21:59:04 +02:00
parent dde8300875
commit 3bf0ddfe17
4 changed files with 31 additions and 12 deletions

View File

@ -140,7 +140,10 @@
// by length from shortest to longest.
// Only titles from 'normal' pages (namespace uid = 0)
// are returned.
// Since the db may be sqlite, we need a try..catch structure
// because sqlite does not support the CHAR_LENGTH function.
$dbr = wfGetDB( DB_SLAVE );
try {
$res = $dbr->select(
'page',
'page_title',
@ -152,6 +155,19 @@
__METHOD__,
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order )
);
} catch (Exception $e) {
$res = $dbr->select(
'page',
'page_title',
array(
'page_namespace = 0',
'LENGTH(page_title) >= ' . $wgLinkTitlesMinimumTitleLength,
'page_title NOT IN ' . $black_list,
),
__METHOD__,
array( 'ORDER BY' => 'LENGTH(page_title) ' . $sort_order )
);
}
// Iterate through the page titles
foreach( $res as $row ) {

View File

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

3
NEWS
View File

@ -1,3 +1,6 @@
LinkTitles 2.2.1: 2013-07-22
* Make the extension work with sqlite databases.
LinkTitles 2.2.0: 2013-04-16
* Fix case-sensitive linking when $wgCapitalLinks is false.

Binary file not shown.