Last modified: 2012-04-17 08:54:01 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T37855, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 35855 - Min and max parameters are treated incorrectly in AllCategories when sorting in reverse
Min and max parameters are treated incorrectly in AllCategories when sorting ...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-10 13:41 UTC by Svick
Modified: 2012-04-17 08:54 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Svick 2012-04-10 13:41:34 UTC
When I want to query for all categories that have at least one member, I can use a query like

http://en.wikipedia.org/w/api.php?action=query&list=allcategories&acprop=size&acdir=ascending&acmin=1

But if I want to them in the reverse order:

http://en.wikipedia.org/w/api.php?action=query&list=allcategories&acprop=size&acdir=descending&acmin=1

the result is wrong. It contains categories with *at most* one member, that's the opposite of what I want.

I think the problem is this line in ApiQueryAllCategories.php:

$this->addWhereRange( 'cat_pages', $dir, $min, $max );

I think this range shouldn't depend on $dir. Changing it to

$this->addWhereRange( 'cat_pages', 'newer', $min, $max );

works fine for me, but I'm not completely sure this is the right solution.
Comment 1 Sam Reed (reedy) 2012-04-10 13:48:28 UTC
That would mean no older support. I suspect you probably want:

if ( $dir == 'newer' ) {
$this->addWhereRange( 'cat_pages', 'newer', $min, $max );
} else {
$this->addWhereRange( 'cat_pages', 'older', $max, $min);
}
Comment 2 Svick 2012-04-10 14:00:42 UTC
I don't understand what you mean. Both mine and your code seem to work exactly the same to me, whether I use acdir=ascending or acdir=descending.

The only difference is that my code produces something like (with acdir=descending&acmin=0&acmax=3):

WHERE (cat_pages>='0') AND (cat_pages<='3') 

while your is:

WHERE (cat_pages<='3') AND (cat_pages>='0')

But I guess I'm missing something.
Comment 3 Sam Reed (reedy) 2012-04-10 14:26:55 UTC
They probably do, but hard coding the direction isn't probably the best idea... It might end up having some unexpected consequence in future...

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links