Extension:GlobalUsage

From MediaWiki.org
(Redirected from Extension:Global Usage)
Jump to: navigation, search


MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
GlobalUsage

Release status:Extension status stable

Screenshot of the GlobalUsage Extension.jpg
ImplementationTemplate:Extension#type Special page, API
DescriptionTemplate:Extension#description Allows to view the global usage of images in a wiki farm with shared image repository
Author(s)Template:Extension#username Bryan Tong Minh (Bryantalk)
Latest versionTemplate:Extension#version 2.2.0
MediaWikiTemplate:Extension#mediawiki 1.28+
Database changesTemplate:Extension#needs-updatephp Yes
LicenseTemplate:Extension#license MIT License
Download
README
Hooks usedTemplate:Extension#hook
LinksUpdateCompleteManual:Hooks/LinksUpdateComplete
ArticleDeleteCompleteManual:Hooks/ArticleDeleteComplete
TitleMoveCompleteManual:Hooks/TitleMoveComplete
FileUndeleteCompleteManual:Hooks/FileUndeleteComplete
UploadCompleteManual:Hooks/UploadComplete
ImagePageAfterImageLinksManual:Hooks/ImagePageAfterImageLinks

Translate the GlobalUsage extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

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.

Install[edit]

  • Download and place the file(s) in a directory called GlobalUsage in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'GlobalUsage' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • In LocalSettings, set $wgGlobalUsageDatabase to the identifier of the wiki where the GlobalUsage data is located (usually the database name). It should be the wiki's id as used by the load balancer. (i.e. It should be the database name. If using a table prefix, it should be dbname-prefix). Example: $wgGlobalUsageDatabase = 'commonswiki';
    This name must also be registered to MediaWiki's load balancer: Manual:$wgLBFactoryConf. This configuration structure maps database names to database servers. Note, you must register all databases used in your wikifarm in this structure, even if they are all on the same database server, for this extension to work.
  • You must use either the $wgConf site configuration system or the Sites db table for GlobalUsage to be able to link to your other wikis. You don't neccesarily have to use it for all your wiki configuration, but it is important to use it for $wgServer and $wgArticlePath.
  • 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. php extensions/GlobalUsage/refreshGlobalimagelinks.php --pages=existing,nonexisting
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

To users running MediaWiki 1.24 or earlier:

The instructions above describe the new way of installing this extension using wfLoadExtension() If you need to install this extension on these earlier versions (MediaWiki 1.24 and earlier), instead of wfLoadExtension( 'GlobalUsage' );, you need to use:

require_once "$IP/extensions/GlobalUsage/GlobalUsage.php";

Specific guide on how to link file usage by sites table[edit]

  1. Make sure that $wgGlobalUsageDatabase and $wgLBFactoryConf were set properily.
  2. Use maintenance script importSites.php to build a XML format site list file. (Instruction could be find here:sitelist.txt, sample file could be find here: sitelist-1.0.xsd.)
  3. Use $wgSharedDB = 'commonswiki'; and $wgSharedTables[] = 'sites'; to share sites table across all wikis.
  4. Clean all cache and force refresh like by refreshGlobalimagelinks.php.

API[edit]

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 gulimit parameter. The guprop parameter sets which properties to retrieve. The gufilterlocal 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: