Extension:GlobalUsage

The GlobalUsage extension allows to view the global usage of images in a wiki farm with shared image repository. It adds Special:GlobalUsage as well as a list of pages that include the image on image description pages.

Installation

 * 1) Download the extension and unpack it in the extensions directory
 * 2) Source GlobalUsage.sql:
 * Note: do this from the wiki installation where you want the GlobalUsage data to be located. Typically this is your shared image repository. Running  on that wiki will also create the table.
 * 1) Edit LocalSettings.php and add to the bottom of the file:
 * 2) In LocalSettings, set   to the identifier of the wiki where the GlobalUsage data is located (usually the database name). It should be something understandable to wfGetDB. Example:
 * At present, this can NOT be a database name of a wiki, but must be a name given in a load balancer configuration: Manual:$wgLBFactoryConf, a complex and largely undocumented configuration structure used by the WMF and Wikia. For a normal mediawiki setup using multiple databases configuring and maintaining this data structures implies significant difficulties.
 * 1) Run refreshGlobalimagelinks.php on all wikis in your farm. This will take a long time, but only needs to be done once when installing the extension.
 * 2) Visit Special:GlobalUsage and enjoy.
 * 1) Visit Special:GlobalUsage and enjoy.

Remarks
To get the right links to the sites and pages under "Global file usage" one of the following conditions must be met
 * the databases follow Wikimedia's database naming convention: languagesuffix like 'enwiki', 'commonswiki' etc.
 * a site configuration object ($wgConf) is created with an array for $wgCanonicalServer and $wgArticlePath for all wikis
 * the extension is patched to use the information in the interwiki table.

API
Extension:GlobalUsage includes an API extension that allows bots and other programs to query the global usage of a file. For example, this query on Wikimedia Commons returns global uses of File:Example.jpg:

By default this returns only 10 results. The next 10 results can be retrieved using the gucontinue parameter included in the result above:

The number of results returned is set with the  parameter. The  parameter sets which properties to retrieve. The  parameter, when set to 1, will exclude uses on the same wiki as the file (e.g. on Commons). The following query retrieves all properties and up to 100 results, excluding local uses: