From 27bcac72e2c28e3bb61fc4afcab8507527d1e6ce Mon Sep 17 00:00:00 2001 From: 20after4 Date: Wed, 15 Mar 2017 19:29:04 +0000 Subject: [PATCH] Revert "Improve sorting on SpecialWanted*-Pages" This reverts commit 5b15728478f9b167389268fb988a7b9f9f78fcf5. The change causes db query errors: DBQueryError: 1054 Unknown column qc_ra.rd_namespace in order clause Change-Id: I068beeae70037c959d42419791911c54ca9908a1 --- includes/specialpage/QueryPage.php | 20 ++++++-------------- includes/specialpage/WantedQueryPage.php | 22 ---------------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index c495f93bc1..40f82f5588 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -407,7 +407,7 @@ abstract class QueryPage extends SpecialPage { $options = isset( $query['options'] ) ? (array)$query['options'] : []; $join_conds = isset( $query['join_conds'] ) ? (array)$query['join_conds'] : []; - if ( $order ) { + if ( count( $order ) ) { $options['ORDER BY'] = $order; } @@ -460,28 +460,20 @@ abstract class QueryPage extends SpecialPage { if ( $limit !== false ) { $options['LIMIT'] = intval( $limit ); } - if ( $offset !== false ) { $options['OFFSET'] = intval( $offset ); } - - $orderFields = $this->getOrderFields(); - $order = []; - $DESC = $this->sortDescending() ? ' DESC' : ''; - foreach ( $orderFields as $field ) { - $order[] = "qc_${field}${DESC}"; - } - if ( $order ) { - $options['ORDER BY'] = $order; + if ( $this->sortDescending() ) { + $options['ORDER BY'] = 'qc_value DESC'; + } else { + $options['ORDER BY'] = 'qc_value ASC'; } - return $dbr->select( 'querycache', [ 'qc_type', 'namespace' => 'qc_namespace', 'title' => 'qc_title', 'value' => 'qc_value' ], [ 'qc_type' => $this->getName() ], - __METHOD__, - $options + __METHOD__, $options ); } diff --git a/includes/specialpage/WantedQueryPage.php b/includes/specialpage/WantedQueryPage.php index 7a1834297c..9d92cbda5b 100644 --- a/includes/specialpage/WantedQueryPage.php +++ b/includes/specialpage/WantedQueryPage.php @@ -119,26 +119,4 @@ abstract class WantedQueryPage extends QueryPage { $label = $this->msg( 'nlinks' )->numParams( $result->value )->escaped(); return Linker::link( $wlh, $label ); } - - /** - * Order by title, overwrites QueryPage::getOrderFields - * - * @return array - */ - function getOrderFields() { - return [ 'value DESC', 'namespace', 'title' ]; - } - - /** - * Do not order descending for all order fields. We will use DESC only on one field, see - * getOrderFields above. This overwrites sortDescending from QueryPage::getOrderFields(). - * Do NOT change this to true unless you remove the phrase DESC in getOrderFiels above. - * If you do a database error will be thrown due to double adding DESC to query! - * - * @return bool - */ - function sortDescending() { - return false; - } - } -- 2.20.1