Freigabestatus: stabil |
|
|---|---|
| 👁 Image |
|
| Einbindung | Spezialseite, API |
| Beschreibung | Allows to view the global usage of images in a wiki farm with shared image repository |
| Autor(en) | Bryan Tong Minh (BryanDiskussion) |
| Letzte Version | 2.2.0 |
| Kompatibilitätspolitik | Snapshots werden zusammen mit MediaWiki veröffentlicht. Der Master ist nicht abwärtskompatibel. |
| MediaWiki | 1.28+ |
| Datenbankänderungen | Ja |
| Virtual domain | virtual-globalusage |
|
|
| Licence | MIT-Lizenz |
| Herunterladen | README |
| Übersetze die GlobalUsage-Erweiterung, wenn sie auf translatewiki.net verfügbar ist | |
| Probleme | Offene Aufgaben · Einen Fehler melden |
The GlobalUsage extension allows viewing the global usage of images in a wiki farm that uses a shared image repository. It adds Special:GlobalUsage as well as a list of pages that include the image on image description pages.
Install
- Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens
GlobalUsageim Ordnerextensions/ablegen.
Entwickler und Code-Beitragende sollten stattdessen die Erweiterung von Git installieren, mit:cdextensions/ gitclonehttps://gerrit.wikimedia.org/r/mediawiki/extensions/GlobalUsage - Folgenden Code am Ende deiner LocalSettings.php-Datei einfügen:
wfLoadExtension( 'GlobalUsage' );
- Führe das Aktualisierungsskript aus, welches automatisch die notwendigen Datenbanktabellen erstellt, die diese Erweiterung braucht.
- In LocalSettings, set
$wgGlobalUsageDatabaseto 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 bedbname-prefix). Example:$wgGlobalUsageDatabase = 'commonswiki';- This name must also be registered to MediaWiki's load balancer: Handbuch:$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 db Handbuch:sites-Tabelle 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/maintenance/refreshGlobalimagelinks.php --pages=existing,nonexisting - 👁 Yes
Erledigt – Navigiere zu Special:Version in deinem Wiki, um zu überprüfen, ob die Erweiterung erfolgreich installiert wurde.
Specific guide on how to link file usage by sites table
- Make sure that $wgGlobalUsageDatabase and $wgLBFactoryConf were set properly.
- Use maintenance script importSites.php to build an XML format site list file. (Instruction can be found here: sitelist.txt, sample file can be found here: sitelist-1.0.xsd.)
- Use $wgSharedDB = 'commonswiki'; and $wgSharedTables[] = 'sites'; to share sites table across all wikis.
- Clean all cache and force refresh like by refreshGlobalimagelinks.php.
Configuration for GlobalUsage (MediaWiki 1.43+)
| MediaWiki Version: | ≥ 1.43 |
In newer versions of GlobalUsage (REL1_45 and newer), $wgGlobalUsageDatabase is no longer used.
The extension now uses MediaWiki's virtual domain system.
The correct configuration variable is $wgVirtualDomainsMapping.
On each content wiki (wikis that use files from the shared repo)
// Must be set BEFORE wfLoadExtension $wgVirtualDomainsMapping['virtual-globalusage'] = [ 'db' => 'my_media_wiki_db' ]; $wgGlobalUsageSharedRepoWiki = 'my_media_wiki_db'; wfLoadExtension( 'GlobalUsage' );
Replace my_media_wiki_db with the $wgDBname of your shared media/file repository wiki.
On the shared media wiki (the wiki that hosts the files)
// Must be set BEFORE wfLoadExtension $wgVirtualDomainsMapping['virtual-globalusage'] = [ 'db' => 'my_media_wiki_db' ]; $wgGlobalUsageSharedRepoWiki = 'my_media_wiki_db'; wfLoadExtension( 'GlobalUsage' ); // Required for WikiMap to resolve wiki IDs to display names and URLs. // Without this, file pages will show raw database names instead of wiki names, and links to pages on other wikis will not work. $wgLocalDatabases = [ 'my_wiki_1_db', 'my_wiki_2_db', 'my_media_wiki_db' ]; $wgConf->wikis = [ 'my_wiki_1_db', 'my_wiki_2_db', 'my_media_wiki_db' ]; $wgConf->suffixes = [ 'mysuffix' ]; // A common suffix shared by your DB names, or any string $wgConf->siteParamsCallback = static function ( $conf, $wiki ) { return [ 'suffix' => 'mysuffix', 'lang' => 'en', 'params' => [], 'tags' => [], ]; }; $wgConf->settings = [ 'wgServer' => [ 'my_wiki_1_db' => 'https://wiki1.example.org', 'my_wiki_2_db' => 'https://wiki2.example.org', 'my_media_wiki_db' => 'https://media.example.org', ], 'wgArticlePath' => [ 'default' => '/wiki/$1', ], 'wgSitename' => [ 'my_wiki_1_db' => 'My Wiki', 'my_wiki_2_db' => 'My Wiki (DE)', 'my_media_wiki_db' => 'My Media Wiki', ], ];
Cross-database access
The DB user for each content wiki must have following privileges on the media wiki's database: SELECT, INSERT, UPDATE, DELETE
If your wikis use separate database users, grant access as a MySQL/MariaDB root user:
GRANTSELECT,INSERT,UPDATE,DELETEONmy_media_wiki_db.*TO'wiki1_user'@'localhost'; GRANTSELECT,INSERT,UPDATE,DELETEONmy_media_wiki_db.*TO'wiki2_user'@'localhost'; FLUSHPRIVILEGES;
Running update.php
After configuring $wgVirtualDomainsMapping, run update.php on each wiki.
GlobalUsage uses addExtensionUpdateOnVirtualDomain, which creates the globalimagelinks table in the correct database (the media wiki's DB).
If globalimagelinks was accidentally created in the wrong database (e.g. before $wgVirtualDomainsMapping was set), drop it and re-run update.php:
DROPTABLEglobalimagelinks;
Backfilling with refreshGlobalimagelinks.php
Run the refresh script from each content wiki only — not from the media wiki.
The script uses the executing wiki's $wgDBname to stamp the gil_wiki field, and writes to the media wiki's database via the virtual domain mapping.
phpextensions/GlobalUsage/maintenance/refreshGlobalimagelinks.php
Running this script from the media wiki itself will result in all rows being stamped with the media wiki's own DB name, and no cross-wiki usage will appear.
Notes
$wgGlobalUsageDatabaseis silently ignored in REL1_45 and newer versions. If you are upgrading from an older version, replace it with$wgVirtualDomainsMappingas shown above.$wgVirtualDomainsMappingmust be set beforewfLoadExtension( 'GlobalUsage' ).$wgConfsettings on the media wiki are required for links to work. Without them, file pages display raw database names (e.g.mywiki_db) with no hyperlink.- The virtual domain name used by this extension is
virtual-globalusage(hardcoded inextension.json).
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:
| Ergebnis |
|---|
<?xml version="1.0"?> <api> <query> <pages> <pagepageid="6428847"ns="6"title="File:Example.jpg"> <globalusage> <gutitle="Ашаблон:Ацқьа"wiki="ab.wikipedia.org"url="http://ab.wikipedia.org/wiki/%D0%90%D1%88%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD:%D0%90%D1%86%D2%9B%D1%8C%D0%B0"/> <gutitle="Wikipedia_ውይይት:Can't_see_the_font?"wiki="am.wikipedia.org"url="http://am.wikipedia.org/wiki/Wikipedia_%E1%8B%8D%E1%8B%AD%E1%8B%AD%E1%89%B5:Can%27t_see_the_font%3F"/> <gutitle="አባል:Blockinblox"wiki="am.wikipedia.org"url="http://am.wikipedia.org/wiki/%E1%8A%A0%E1%89%A3%E1%88%8D:Blockinblox"/> <gutitle="አባል_ውይይት:Hana.oww"wiki="am.wikipedia.org"url="http://am.wikipedia.org/wiki/%E1%8A%A0%E1%89%A3%E1%88%8D_%E1%8B%8D%E1%8B%AD%E1%8B%AD%E1%89%B5:Hana.oww"/> <gutitle="አባል:Beza"wiki="am.wikipedia.org"url="http://am.wikipedia.org/wiki/%E1%8A%A0%E1%89%A3%E1%88%8D:Beza"/> <gutitle="መደብ:ኪነት"wiki="am.wikipedia.org"url="http://am.wikipedia.org/wiki/%E1%88%98%E1%8B%B0%E1%89%A5:%E1%8A%AA%E1%8A%90%E1%89%B5"/> <gutitle="መደብ_ውይይት:ተረትና_ምሳሌ"wiki="am.wikipedia.org"url="http://am.wikipedia.org/wiki/%E1%88%98%E1%8B%B0%E1%89%A5_%E1%8B%8D%E1%8B%AD%E1%8B%AD%E1%89%B5:%E1%89%B0%E1%88%A8%E1%89%B5%E1%8A%93_%E1%88%9D%E1%88%B3%E1%88%8C"/> <gutitle="ስዕል:መርጡለ_ማርያም_ገዳም_.jpg"wiki="am.wikipedia.org"url="http://am.wikipedia.org/wiki/%E1%88%B5%E1%8B%95%E1%88%8D:%E1%88%98%E1%88%AD%E1%8C%A1%E1%88%88_%E1%88%9B%E1%88%AD%E1%8B%AB%E1%88%9D_%E1%8C%88%E1%8B%B3%E1%88%9D_.jpg"/> <gutitle="User_talk:Rasheduzzaman_Raj"wiki="ang.wikipedia.org"url="http://ang.wikipedia.org/wiki/User_talk:Rasheduzzaman_Raj"/> <gutitle="User:Danceteamcherleaders"wiki="ang.wikipedia.org"url="http://ang.wikipedia.org/wiki/User:Danceteamcherleaders"/> </globalusage> </page> </pages> </query> <query-continue> <globalusagegucontinue="Example.jpg|arwiki|77967"/> </query-continue> </api> |
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:
| 👁 Image | Diese Erweiterung wird in einem oder mehreren Wikis von Wikimedia verwendet. Das bedeutet mit hoher Wahrscheinlichkeit, dass die Erweiterung stabil ist und gut genug funktioniert, um auf solch häufig besuchten Webseiten benutzt zu werden. Suche nach dem Erweiterungs-Namen in den Wikimedia CommonSettings.php und den InitialiseSettings.php-Konfigurations-Dateien, um nachzusehen, wo es installiert ist. Eine vollständige Liste der installierten Erweiterungen in einem bestimmten Wiki wird auf Special:Version im Wiki generiert und angezeigt. |
| 👁 Image | Diese Erweiterung ist in den folgenden Softwarepaketen enthalten und/oder wird von den folgenden Wiki-Farmen, bzw. Wiki-Hostern verwendet: |
- Stable extensions/de
- Special page extensions/de
- API extensions/de
- ArticleDeleteComplete extensions/de
- FileDeleteComplete extensions/de
- FileUndeleteComplete extensions/de
- ImagePageAfterImageLinks extensions/de
- ImagePageShowTOC extensions/de
- LinksUpdateComplete extensions/de
- LoadExtensionSchemaUpdates extensions/de
- PageMoveComplete extensions/de
- UploadComplete extensions/de
- WgQueryPages extensions/de
- MIT licensed extensions/de
- Extensions in Wikimedia version control/de
- All extensions/de
- Extensions used on Wikimedia/de
- Extensions included in Miraheze/de
- Extensions included in Weird Gloop/de
- Extensions for data exchange with other local wikis/de
