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,18 +140,34 @@
// 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 );
$res = $dbr->select(
'page',
'page_title',
array(
'page_namespace = 0',
'CHAR_LENGTH(page_title) >= ' . $wgLinkTitlesMinimumTitleLength,
'page_title NOT IN ' . $black_list,
),
__METHOD__,
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order )
);
try {
$res = $dbr->select(
'page',
'page_title',
array(
'page_namespace = 0',
'CHAR_LENGTH(page_title) >= ' . $wgLinkTitlesMinimumTitleLength,
'page_title NOT IN ' . $black_list,
),
__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 ) {