X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=inline;f=includes%2Fspecialpage%2FQueryPage.php;h=3b3ea26f2d301563eea355d2096f9083ba3fa7a0;hb=8151aebc686e1aaaa8acea7e087c011915646f18;hp=40f82f558822b12f4254d9b4c11166f4df66ace1;hpb=d4a1177aa66759a5cf05887830435bb9e50f7780;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index 40f82f5588..3b3ea26f2d 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -304,7 +304,7 @@ abstract class QueryPage extends SpecialPage { return 0; } - $fname = get_class( $this ) . '::recache'; + $fname = static::class . '::recache'; $dbw = wfGetDB( DB_MASTER ); if ( !$dbw ) { return false; @@ -389,7 +389,7 @@ abstract class QueryPage extends SpecialPage { * @since 1.18 */ public function reallyDoQuery( $limit, $offset = false ) { - $fname = get_class( $this ) . "::reallyDoQuery"; + $fname = static::class . '::reallyDoQuery'; $dbr = $this->getRecacheDB(); $query = $this->getQueryInfo(); $order = $this->getOrderFields(); @@ -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 ( count( $order ) ) { + if ( $order ) { $options['ORDER BY'] = $order; } @@ -460,27 +460,35 @@ abstract class QueryPage extends SpecialPage { if ( $limit !== false ) { $options['LIMIT'] = intval( $limit ); } + if ( $offset !== false ) { $options['OFFSET'] = intval( $offset ); } - if ( $this->sortDescending() ) { - $options['ORDER BY'] = 'qc_value DESC'; - } else { - $options['ORDER BY'] = 'qc_value ASC'; + + $orderFields = $this->getOrderFields(); + $order = []; + $DESC = $this->sortDescending() ? ' DESC' : ''; + foreach ( $orderFields as $field ) { + $order[] = "qc_${field}${DESC}"; + } + if ( $order ) { + $options['ORDER BY'] = $order; } + return $dbr->select( 'querycache', [ 'qc_type', 'namespace' => 'qc_namespace', 'title' => 'qc_title', 'value' => 'qc_value' ], [ 'qc_type' => $this->getName() ], - __METHOD__, $options + __METHOD__, + $options ); } public function getCachedTimestamp() { if ( is_null( $this->cachedTimestamp ) ) { $dbr = wfGetDB( DB_REPLICA ); - $fname = get_class( $this ) . '::getCachedTimestamp'; + $fname = static::class . '::getCachedTimestamp'; $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp', [ 'qci_type' => $this->getName() ], $fname ); }