Do not allow sorting Special:Listfiles by img_name when filtering by username
authorBrian Wolff <bawolff+wn@gmail.com>
Thu, 18 Apr 2013 23:56:35 +0000 (20:56 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Fri, 5 Jul 2013 19:05:46 +0000 (16:05 -0300)
We don't allow sorting by img_size due to lack of index. For consistency
we shouldn't allow by img_name either, since there is similarly
no index on (img_user_text, img_name) either

Also, let filtering by img_size when not in miser mode.

Change-Id: I5aaf1a3f39ddc23d5d009ada199b63a0e3133ef3

RELEASE-NOTES-1.22
includes/specials/SpecialListfiles.php

index 24081db..bee178d 100644 (file)
@@ -187,6 +187,8 @@ production.
   the #toc CSS id and the .toc CSS class). However, particularly bad abuse of
   the id or the class can possibly break.
 * CSSJanus now supports rgb, hsl, rgba, and hsla color syntaxes.
+* Special:Listfiles can no longer be sorted by image name when filtering
+  by user in miser mode.
 
 === API changes in 1.22 ===
 * (bug 25553) The JSON output formatter now leaves forward slashes unescaped
index 070cdea..24bd19f 100644 (file)
@@ -134,13 +134,18 @@ class ImageListPager extends TablePager {
        }
 
        function isFieldSortable( $field ) {
+               global $wgMiserMode;
                if ( $this->mIncluding ) {
                        return false;
                }
-               static $sortable = array( 'img_timestamp', 'img_name' );
-               if ( $field == 'img_size' ) {
-                       # No index for both img_size and img_user_text
-                       return !isset( $this->mQueryConds['img_user_text'] );
+               $sortable = array( 'img_timestamp', 'img_name', 'img_size' );
+               if ( $wgMiserMode && isset( $this->mQueryConds['img_user_text'] ) ) {
+                       // If we're sorting by user, the index only supports sorting by time
+                       if ( $field === 'img_timestamp' ) {
+                               return true;
+                       } else {
+                               return false;
+                       }
                }
 
                return in_array( $field, $sortable );