From: Greg Sabino Mullane Date: Sun, 2 Sep 2007 18:03:10 +0000 (+0000) Subject: Add implicitOrderby() to make sure that SpecialAllpages uses an ORDER BY when needed. X-Git-Tag: 1.31.0-rc.0~51555 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=8eb82ee4070425ee4639960a4fc74a1d195fefff;p=lhc%2Fweb%2Fwiklou.git Add implicitOrderby() to make sure that SpecialAllpages uses an ORDER BY when needed. Made this an option rather than forcing the ORDER BY as testing show MySQL is faster without it for large tables. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fd46bf5bc9..3528f674ca 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -429,6 +429,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 8393) and need to be preserved (without attributes) for entries in the table of contents * (bug 11114) Fix regression in read-only mode error display during editing +* Force non-MySQL databases to use an ORDER BY in SpecialAllpages to ensure + that the first page_title is truly the first page title. == API changes since 1.10 == diff --git a/includes/Database.php b/includes/Database.php index 5387ed411a..4f8c7d5e10 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -440,6 +440,14 @@ class Database { return true; } + /** + * Returns true if this database does an implicit order by when the column has an index + * For example: SELECT page_title FROM page LIMIT 1 + */ + function implicitOrderby() { + return true; + } + /** * Returns true if this database can do a native search on IP columns * e.g. this works as expected: .. WHERE rc_ip = '127.42.12.102/32'; diff --git a/includes/DatabaseOracle.php b/includes/DatabaseOracle.php index 27e85297a0..38485481c6 100644 --- a/includes/DatabaseOracle.php +++ b/includes/DatabaseOracle.php @@ -128,6 +128,9 @@ class DatabaseOracle extends Database { function implicitGroupby() { return false; } + function implicitOrderby() { + return false; + } function searchableIPs() { return true; } diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index 113be2c046..32c061a00d 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -102,6 +102,9 @@ class DatabasePostgres extends Database { function implicitGroupby() { return false; } + function implicitOrderby() { + return false; + } function searchableIPs() { return true; } diff --git a/includes/SpecialAllpages.php b/includes/SpecialAllpages.php index 8599cbf9dc..07ff120b29 100644 --- a/includes/SpecialAllpages.php +++ b/includes/SpecialAllpages.php @@ -101,7 +101,11 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) { $lines = $wgMemc->get( $key ); if( !is_array( $lines ) ) { - $firstTitle = $dbr->selectField( 'page', 'page_title', $where, $fname, array( 'LIMIT' => 1 ) ); + $options = array( 'LIMIT' => 1 ); + if ( ! $dbr->implicitOrderby() ) { + $options['ORDER BY'] = 'page_title'; + } + $firstTitle = $dbr->selectField( 'page', 'page_title', $where, $fname, $options ); $lastTitle = $firstTitle; # This array is going to hold the page_titles in order. @@ -293,8 +297,11 @@ function showChunk( $namespace = NS_MAIN, $from, $including = false ) { } else { # The previous chunk is not complete, need to link to the very first title # available in the database - $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', array( 'page_namespace' => $namespace ), $fname, array( 'LIMIT' => 1) ); - + $options = array( 'LIMIT' => 1 ); + if ( ! $dbr->implicitOrderby() ) { + $options['ORDER BY'] = 'page_title'; + } + $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', array( 'page_namespace' => $namespace ), $fname, $options ); # Show the previous link if it s not the current requested chunk if( $from != $reallyFirstPage_title ) { $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title );