RCFilters: Work around IE11 rendering issues
[lhc/web/wiklou.git] / includes / specialpage / QueryPage.php
index 65e82e8..68d2d30 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
 
 /**
  * This is a class for doing query pages; since they're almost all the same,
@@ -407,7 +408,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;
                        }
 
@@ -457,26 +458,46 @@ abstract class QueryPage extends SpecialPage {
        public function fetchFromCache( $limit, $offset = false ) {
                $dbr = wfGetDB( DB_REPLICA );
                $options = [];
+
                if ( $limit !== false ) {
                        $options['LIMIT'] = intval( $limit );
                }
+
                if ( $offset !== false ) {
                        $options['OFFSET'] = intval( $offset );
                }
+
+               $order = $this->getCacheOrderFields();
                if ( $this->sortDescending() ) {
-                       $options['ORDER BY'] = 'qc_value DESC';
-               } else {
-                       $options['ORDER BY'] = 'qc_value ASC';
+                       foreach ( $order as &$field ) {
+                               $field .= " DESC";
+                       }
+               }
+               if ( $order ) {
+                       $options['ORDER BY'] = $order;
                }
-               return $dbr->select( 'querycache', [ 'qc_type',
+
+               return $dbr->select( 'querycache',
+                               [ 'qc_type',
                                'namespace' => 'qc_namespace',
                                'title' => 'qc_title',
                                'value' => 'qc_value' ],
                                [ 'qc_type' => $this->getName() ],
-                               __METHOD__, $options
+                               __METHOD__,
+                               $options
                );
        }
 
+       /**
+        * Return the order fields for fetchFromCache. Default is to always use
+        * "ORDER BY value" which was the default prior to this function.
+        * @return array
+        * @since 1.29
+        */
+       function getCacheOrderFields() {
+               return [ 'value' ];
+       }
+
        public function getCachedTimestamp() {
                if ( is_null( $this->cachedTimestamp ) ) {
                        $dbr = wfGetDB( DB_REPLICA );