Last modified: 2014-04-22 07:49:24 UTC
Most of the ForeignAPIRepo methods search recursively. For example, if you have a ForeignAPIRepo pointing to enwiki, asking it for File:Example.svg will return the Commons image by that name. But this doesn't apply to ForeignAPIRepo::findBySha1. Querying eb2a8759ddf38da50f60feb11f7208f5ec11daac (currently the sha of [[commons:File:Example.svg]]) against that enwiki ForeignAPIRepo returns nothing. I can think of 4 possible solutions. In decreasing order of complexity: 1. Add a "recursive" option to list=allimages (or a "localonly", if we want to make recursive operation the default). This would need all FileRepo subclasses to support some interface for all the other modes of list=allimages, such as "give me $limit files starting from $name" and "give me $limit file starting from $timestamp" (both ascending or descending). 2. Add a "list=allfilesbysha1" API module, that would basically call findBySha1s and return the results. Note it would need extra checks so that querying enwiki for d01b79a6781c72ac9bfff93e5e2cfbeef4efc840 wouldn't return Commons' File:Example.jpg (which is shadowed by enwiki's File:Example.jpg). 3. Make ForeginAPIRepo be local only. So if someone wants enwiki and commons as foreign repos, they need to configure two ForeginAPIRepos instead of just the one for enwiki. This is currently about a 4-line change, just adding 'localonly' to the prop=imageinfo queries. 4. Pretend it's not really a problem. ;) Personally, I like #3. If we don't go with that here then I'll probably submit a patch to make "localOnly" an option for ForeignAPIRepo.
I've heard of quite a few people relying on foreign api being recursive. One also has to be careful of people who include both enwiki and say dewiki as foreign repos. the recursiveness would make it list commons file twice. (Already somewhat of a problem)
I find the proposed label 'recursive' confusing; I'd expect the behavior of "return all matching media, regardless of which backend they happen to be on" behavior by default from something called list=allimages to begin with... Is that a bug with list=allimages?