Last modified: 2012-04-30 11:09:22 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 T28909, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 26909 - Implement 'dir' for query properties.
Implement 'dir' for query properties.
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.18.x
All All
: Normal enhancement (vote)
: 1.20.0 release
Assigned To: Roan Kattouw
: patch, patch-reviewed
: 36343 (view as bug list)
Depends on:
Blocks: 12907
  Show dependency treegraph
 
Reported: 2011-01-24 21:17 UTC by Krinkle
Modified: 2012-04-30 11:09 UTC (History)
8 users (show)

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


Attachments
add dir param for prop=links|templates|categories|extlinks|iwlinks|langlinks|images|duplicatefiles (12.31 KB, patch)
2011-11-13 12:17 UTC, Umherirrender
Details
fix for the dir param in prop=links|templates|categories|iwlinks|langlinks|images|duplicatefiles (5.95 KB, patch)
2011-12-17 14:22 UTC, Umherirrender
Details

Description Krinkle 2011-01-24 21:17:12 UTC
Currently it's required to save the previous query-continue somewhere or even having to construct it ourselfs to page back from somewhere.

For example, the following query is a "page 3":

http://commons.wikimedia.org/w/api.php?format=jsonfm&action=query&titles=User%3AKrinkle%2FTestcase&tllimit=2&prop=templates&tlcontinue=12796614|10|BUser

How to get (back) to "page 2" ?
Comment 1 Roan Kattouw 2011-01-25 01:17:04 UTC
(In reply to comment #0)
> Currently it's required to save the previous query-continue somewhere or even
> having to construct it ourselfs to page back from somewhere.
> 
> For example, the following query is a "page 3":
> 
> http://commons.wikimedia.org/w/api.php?format=jsonfm&action=query&titles=User%3AKrinkle%2FTestcase&tllimit=2&prop=templates&tlcontinue=12796614|10|BUser
> 
> How to get (back) to "page 2" ?
By saving the q-continue, like you said, or by reversing the dir parameter and passing the same continue value (no guarantee that this'll actually work).

There's no way to handle the general case efficiently, DB-wise, so WONTFIX.
Comment 2 Krinkle 2011-01-25 01:39:04 UTC
(In reply to comment #1)
> by reversing the dir parameter and passing the same continue value (no guarantee that this'll actually work).

You mentioned this on IRC as well, but I have found no such parameter (tried different things and looked at the documentation). 

> 
> There's no way to handle the general case efficiently, DB-wise, so WONTFIX.

Fair enough :)
Comment 3 Roan Kattouw 2011-01-25 01:43:58 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > by reversing the dir parameter and passing the same continue value (no guarantee that this'll actually work).
> 
> You mentioned this on IRC as well, but I have found no such parameter (tried
> different things and looked at the documentation). 
> 
It's not called 'dir', but 'apdir' for allpages, 'rvdir' for revisions, etc.
Comment 4 Krinkle 2011-01-25 09:56:16 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > by reversing the dir parameter and passing the same continue value (no guarantee that this'll actually work).
> > 
> > You mentioned this on IRC as well, but I have found no such parameter (tried
> > different things and looked at the documentation). 
> > 
> It's not called 'dir', but 'apdir' for allpages, 'rvdir' for revisions, etc.

For lists yes, but not for properties.

For lists there's 'from' and 'dir':
http://www.mediawiki.org/w/api.php?action=query&list=allpages
http://www.mediawiki.org/w/api.php?action=query&list=allpages&apfrom=$wgAllowAnonymousMinor
http://www.mediawiki.org/w/api.php?action=query&list=allpages&apfrom=$wgAllowAnonymousMinor&apdir=descending

But there's no 'dir' for properties

http://www.mediawiki.org/w/api.php?action=query&titles=MediaWiki&prop=links&pllimit=2
http://www.mediawiki.org/w/api.php?action=query&titles=MediaWiki&prop=links&pllimit=2&plcontinue=1|0|Developer%20hub
Comment 5 Roan Kattouw 2011-01-25 18:52:28 UTC
(In reply to comment #4)
> But there's no 'dir' for properties
> 
> http://www.mediawiki.org/w/api.php?action=query&titles=MediaWiki&prop=links&pllimit=2
> http://www.mediawiki.org/w/api.php?action=query&titles=MediaWiki&prop=links&pllimit=2&plcontinue=1|0|Developer%20hub

Hmm, good point. We should have them there too.
Comment 6 Krinkle 2011-01-25 18:53:59 UTC
Re-opened with adjusted summary.
Comment 7 Umherirrender 2011-11-13 12:17:04 UTC
Created attachment 9435 [details]
add dir param for prop=links|templates|categories|extlinks|iwlinks|langlinks|images|duplicatefiles

The attached patch adds a dir param to prop=links|templates|categories|extlinks|iwlinks|langlinks|images|duplicatefiles

The other modules have a dir param (revisions) or in my opinion it makes no sense (info|categoriyinfo|pageprops|stashimageinfo|imageinfo).

It also changed the handling of ORDER BY in ApiQueryBase::addWhereRange. This is needed, because the order by can given as array and that was not handled there.

Feel free to modify the patch.

Thanks.
Comment 8 Roan Kattouw 2011-11-14 08:26:52 UTC
(In reply to comment #7)
> Created attachment 9435 [details]
> add dir param for
> prop=links|templates|categories|extlinks|iwlinks|langlinks|images|duplicatefiles
> 
Thanks for the patch. Modified patch committed in r102947.

> It also changed the handling of ORDER BY in ApiQueryBase::addWhereRange. This
> is needed, because the order by can given as array and that was not handled
> there.
> 
Good catch. I cleaned up the ApiQueryBase changes a bit before committing. It looked like it would've generated a notice because the access to $this->options['ORDER BY'] wasn't protected with isset() (there was an isset call nearby, but 1) the array access was done unconditionally anyway and 2) isset was called on a variable that was set unconditionally, which means it was used to check for null, which is evil) and the logic with wrapping a non-array value in an array could be replaced with an (array) cast. I ended up using:

$optionOrderBy = isset( $this->options['ORDER BY'] ) ? (array)$this->options['ORDER BY'] : array();
$optionOrderBy[] = $order;

> Feel free to modify the patch.
> 
The only other modification I made was to drop the ApiQueryExternalLinks.php changes. They added an ORDER BY on el_to which is a partially-indexed blob field, so that would filesort. The query isn't very nice as it is, but this would make it worse.
Comment 9 Umherirrender 2011-11-14 11:01:17 UTC
Thank you for review and commit.

(In reply to comment #8)
> (In reply to comment #7)
> > Feel free to modify the patch.
> > 
> The only other modification I made was to drop the ApiQueryExternalLinks.php
> changes. They added an ORDER BY on el_to which is a partially-indexed blob
> field, so that would filesort. The query isn't very nice as it is, but this
> would make it worse.

It there a way to get the dir param also for ApiQueryExternalLinks.php? Should I create a new bug to track this (and which gets maybe LATER or WONTFIX)? Thanks.
Comment 10 Roan Kattouw 2011-11-14 11:05:27 UTC
(In reply to comment #9)
> It there a way to get the dir param also for ApiQueryExternalLinks.php? Should
> I create a new bug to track this (and which gets maybe LATER or WONTFIX)?
> Thanks.
You should submit a new patch, either on this bug or on a new one (I don't really care) that doesn't add the order by on el_to. I realize this may mean the result set isn't completely reversed,  but that's unavoidable; it's either that or no dir param at all.
Comment 11 Umherirrender 2011-11-14 12:21:22 UTC
backed out to bug 32401
Comment 12 Umherirrender 2011-12-17 14:22:42 UTC
Created attachment 9730 [details]
fix for the dir param in prop=links|templates|categories|iwlinks|langlinks|images|duplicatefiles

Now you cannot continue with dir=descending, because you get the same result. I have create a patch, to fix that problem in each prop module. Thanks.
Comment 13 Krinkle 2012-01-02 15:59:30 UTC
Roan already committed r102947. Is this bug fixed ? Or is this new patch a follow-up that fixes something ?
Comment 14 Umherirrender 2012-01-04 18:51:22 UTC
(In reply to comment #13)
> Roan already committed r102947. Is this bug fixed ? Or is this new patch a
> follow-up that fixes something ?

It is a follow up, which fix the navigation with 'dir' and 'continue'.
Comment 15 Umherirrender 2012-03-30 21:24:59 UTC
commited the second patch with Gerrit change #4028
Comment 16 Umherirrender 2012-04-21 09:19:19 UTC
successfully merged
Comment 17 Svick 2012-04-30 11:09:22 UTC
*** Bug 36343 has been marked as a duplicate of this bug. ***

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


Navigation
Links