HomePhabricator

Bifurcate imageinfo queries to improve performance

Authored by Mholloway on Apr 2 2019, 2:11 PM.

Description

Bifurcate imageinfo queries to improve performance

When the Action API is queried on a non-Commons wiki (e.g., a Wikipedia)
for imageinfo, the API code first searches for the requested data in the
wiki's local file repository, then falls back to the Commons file
repository (where most files in use on the wikis are actually located).

This patch improves the performance of the /page/media endpoint by using
the upload.wikimedia.org URL paths to identify whether the file is
located in Commons or the local wiki's file repository, then directing
imageinfo requests directly to the appropriate wiki.

Based on local performance testing, this consistently saves about 100 ms
on the average request.

Note: This also adds a new "repository" field to results, containing as a
value either "commons" or "local".

Change-Id: I7ff6241bfa110aad113a33dc4caeb5342ad67604