RCFilters: Work around IE11 rendering issues
[lhc/web/wiklou.git] / includes / specialpage / QueryPage.php
index 3b3ea26..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,
@@ -457,6 +458,7 @@ abstract class QueryPage extends SpecialPage {
        public function fetchFromCache( $limit, $offset = false ) {
                $dbr = wfGetDB( DB_REPLICA );
                $options = [];
+
                if ( $limit !== false ) {
                        $options['LIMIT'] = intval( $limit );
                }
@@ -465,17 +467,18 @@ abstract class QueryPage extends SpecialPage {
                        $options['OFFSET'] = intval( $offset );
                }
 
-               $orderFields = $this->getOrderFields();
-               $order = [];
-               $DESC = $this->sortDescending() ? ' DESC' : '';
-               foreach ( $orderFields as $field ) {
-                       $order[] = "qc_${field}${DESC}";
+               $order = $this->getCacheOrderFields();
+               if ( $this->sortDescending() ) {
+                       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' ],
@@ -485,6 +488,16 @@ abstract class QueryPage extends SpecialPage {
                );
        }
 
+       /**
+        * 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 );