(bug 27202) Add timestamp sort to list=allimages
authormartineznovo <martineznovo@gmail.com>
Sun, 16 Sep 2012 20:00:37 +0000 (22:00 +0200)
committerBrad Jorsch <bjorsch@wikimedia.org>
Mon, 3 Dec 2012 15:36:42 +0000 (10:36 -0500)
commit529db96cdc31c5a1870ee0df623f21912a73c9aa
tree81546769b7ef38402f40ace8c9bc5e18ce1af91d
parentbd6f3ddc6f8f5a42f9ac335da5cc82f9e2a0be62
(bug 27202) Add timestamp sort to list=allimages

New parameter 'sort' that defaults to 'name' so if not specified it will
act exactly as before.

Changes in the access to $params['dir'] to a boolean variable
$ascendingOrder in a try to be more meaningful.

Some existing filtering parameters are mutually exclusive with new ones.
The reason is because the table is sorted by name, as primary key, while
sorting by timestamp use the timestamp or usertext_timestamp index which
is not the primary key, thus filtering and ordering by different indices
doesn't make an efficient index usage.

Exceptions are:
* mime: disabled in Miser Mode
* size: although there's apparently no use for this when sorting by
  timestamp, there's an index on that and the EXPLAIN doesn't use filesort
  algorythm (unlike other combinations):

EXPLAIN
select img_name, img_user_text, img_timestamp
from image
where img_size>=1000 and img_size<=20000
and img_timestamp > '20120916153705'
ORDER BY img_timestamp\G

* Same for sha1 (see comment on Patchset 1)

In function run:

* Added USE INDEX query options when sort=timestamp to ensure the proper
  index is being used.
* Table selection and result fields moved at top, then filter parameters,
  and finally order by and options.

Parameter description and definition sorted by purpose: sort and dir
first, then pagination, result fields, filters and limit.

Change-Id: Ide2ff3dbc3e617e749685d558444854617535bab
RELEASE-NOTES-1.21
includes/api/ApiQueryAllImages.php