Page MenuHomePhabricator

Min and max parameters are treated incorrectly in AllCategories when sorting in reverse
Closed, ResolvedPublic


When I want to query for all categories that have at least one member, I can use a query like

But if I want to them in the reverse order:

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.

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:11 AM
bzimport set Reference to bz35855.
bzimport added a subscriber: Unknown Object (MLST).

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);

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.

They probably do, but hard coding the direction isn't probably the best idea... It might end up having some unexpected consequence in future...