Extension talk:GlobalUsage
This page used the Structured Discussions extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made. |
usage of API features
Can you please provide documentation on how to use the API features of this extension? Thanks Tisane 11:31, 22 March 2010 (UTC) 21:33, 5 January 2012 (UTC)
No command line access
Hi,
I would like to install GlobalUsage, but I have no command line access. I was able to circumvent step 2 by copying the SQL query in phpMyAdmin, but I now have to run refreshGlobalimagelinks.php, which cannot be done from the browser. Is there any way to run this script without a command line access?
Thank you, Llamaggot 12:46, 12 February 2012 (UTC)
Prefix of table globalimagelinks
Hi,
GlobalUsage.sql creates a table named 'prefix_globalimagelinks' (if 'prefix_' is the value of $wgDBprefix), but the extension is only working if this table is called 'globalimagelinks' instead, without the prefix.
Should GlobalUsage.sql be fixed? Or is there a way to make the extension work with the prefixed table name?
Thanks in advance, ~Llamaggot (talk) 09:54, 19 September 2012 (UTC)
- The database code resolves the canonical name into the actual name (adding the prefix) automatically. If this doesn't happen that can mean one of two things:
- There is a bug in MediaWiki core where it doesn't do it properly
- The GlobalUsage extension is using raw queries instead of abstracted through MediaWiki's handler.
- Please file a bug on Bugzilla (Product: MediaWiki extensions; Component: GlobalUsage). Be sure to include the version of your wiki and the version of GlobalUsage (you can get this information by going to Special:Version on your wiki). If possible, also include a link to your wiki in the bug report. Thanks! Krinkle (talk) 01:00, 21 September 2012 (UTC)
Change display
How do I change the usage display from "DataBase name" to "Sitename" ? Mlpearc (powwow) 18:26, 6 February 2013 (UTC)
- Image now at: http://mywiki.everythingfoodanddrink.org/wiki/File:GlobalUsage_screenshot.jpg
- A fix is in the thread "Links under Global file usage". Egel (talk) 12:11, 11 November 2014 (UTC)
easier way for $wgGlobalUsageDatabase
There is an easier way than setting $wgGlobalUsageDatabase using Manual:$wgLBFactoryConf: using $wgSharedDB and $wgSharedTables :-)
Add the following to LocalSettings.php in all your wikis:
(I'm assuming you have "images-wiki" as your shared images wiki)
if ( $wgDBname != "images-wiki" ) { $wgSharedDB = "images-wiki"; $wgSharedTables[] = 'globalimagelinks'; } require_once("$IP/extensions/GlobalUsage/GlobalUsage.php"); if ( $wgDBname == "images-wiki" ) { $wgGlobalUsageDatabase = 'images-wiki'; # workaround to enforce displaying the "global usage" section }
(Note: $wgSharedTables defaults to ('user', 'user_properties') - remove them if you want)
HTH ;-) Cboltz (talk) 15:29, 6 August 2013 (UTC)
- That was pretty helpful, thanks a lot!
- Cheers, Till Kraemer (talk) 17:26, 11 February 2014 (UTC)
Links under Global file usage
What must you do to get links to the sites and pages under Global file usage? I only get the database name and the names of the pages with underscores. example Egel (talk) 10:01, 17 March 2014 (UTC)
- What I have found is that the functions that take care of this are very wikipedia specific. Those functions only work right when the database name is like enwiki, with "en" the language code and "wiki" the sitename. Egel (talk) 14:24, 4 September 2014 (UTC)
- I have put a version that should work on all database naming conventions here, please test
- the patch:
- Egel (talk) 20:03, 8 September 2014 (UTC)
-------------------------------------- diff -u GlobalUsage/ApiQueryGlobalUsage.php mediawiki-extensions-GlobalUsage/ApiQueryGlobalUsage.php --- GlobalUsage/ApiQueryGlobalUsage.php 2014-09-11 14:58:21.571751756 +0200 +++ mediawiki-extensions-GlobalUsage/ApiQueryGlobalUsage.php 2014-09-11 14:56:48.934133602 +0200 @@ -30,6 +30,7 @@ public function execute() { $params = $this->extractRequestParams(); $prop = array_flip( $params['prop'] ); + foreach(Interwiki::getAllPrefixes(1) as $k) { $interWikis[$k[iw_wikiid]] = $k[iw_prefix];}; $pageIds = $this->getPageSet()->getAllTitlesByNamespace(); if ( !empty( $pageIds[NS_FILE] ) ) { @@ -52,6 +53,7 @@ foreach ( $query->getResult() as $image => $wikis ) { $pageId = intval( $pageIds[$image] ); foreach ( $wikis as $wiki => $result ) { + $interwiki = Interwiki::fetch($interWikis[$wiki]); foreach ( $result as $item ) { if ( $item['namespace'] ) { $title = "{$item['namespace']}:{$item['title']}"; @@ -60,11 +62,11 @@ } $result = array( 'title' => $title, - 'wiki' => WikiMap::getWikiName( $wiki ) + 'wiki' => parse_url($interwiki->getURL(), PHP_URL_HOST) ); if ( isset( $prop['url'] ) ) { /* We expand the url because we don't want protocol relative urls in API results */ - $result['url'] = wfExpandUrl( WikiMap::getForeignUrl( $item['wiki'], $title ), PROTO_CURRENT ); + $result['url'] = $interwiki->getURL($title); } if ( isset( $prop['pageid'] ) ) { $result['pageid'] = $item['id']; Gemeenschappelijke submappen: GlobalUsage/.git en mediawiki-extensions-GlobalUsage/.git diff -u GlobalUsage/GlobalUsageImagePageHooks.php mediawiki-extensions-GlobalUsage/GlobalUsageImagePageHooks.php --- GlobalUsage/GlobalUsageImagePageHooks.php 2014-09-11 14:58:21.571751756 +0200 +++ mediawiki-extensions-GlobalUsage/GlobalUsageImagePageHooks.php 2014-09-11 14:56:48.938133662 +0200 @@ -42,18 +42,20 @@ $context = $imagePage->getContext(); $title = $imagePage->getFile()->getTitle(); $targetName = $title->getText(); + foreach(Interwiki::getAllPrefixes(1) as $k) { $interWikis[$k[iw_wikiid]] = $k[iw_prefix];}; $query = self::getImagePageQuery( $title ); $guHtml = ''; foreach ( $query->getSingleImageResult() as $wiki => $result ) { - $wikiName = WikiMap::getWikiName( $wiki ); + $interwiki = Interwiki::fetch($interWikis[$wiki]); + $wikiName = parse_url($interwiki->getURL(), PHP_URL_HOST); $escWikiName = Sanitizer::escapeClass( $wikiName ); $guHtml .= "<li class='mw-gu-onwiki-$escWikiName'>" . $context->msg( 'globalusage-on-wiki', $targetName, $wikiName )->parse() . "\n<ul>"; foreach ( $result as $item ) - $guHtml .= "\t<li>" . SpecialGlobalUsage::formatItem( $item ) . "</li>\n"; + $guHtml .= "\t<li>" . SpecialGlobalUsage::formatItem( $item, $interwiki ) . "</li>\n"; $guHtml .= "</ul></li>\n"; } Gemeenschappelijke submappen: GlobalUsage/i18n en mediawiki-extensions-GlobalUsage/i18n Gemeenschappelijke submappen: GlobalUsage/patches en mediawiki-extensions-GlobalUsage/patches diff -u GlobalUsage/SpecialGlobalUsage.php mediawiki-extensions-GlobalUsage/SpecialGlobalUsage.php --- GlobalUsage/SpecialGlobalUsage.php 2014-09-11 14:58:21.571751756 +0200 +++ mediawiki-extensions-GlobalUsage/SpecialGlobalUsage.php 2014-09-11 14:56:48.938133662 +0200 @@ -91,6 +91,7 @@ private function showResult() { $query = new GlobalUsageQuery( $this->target ); $request = $this->getRequest(); + foreach(Interwiki::getAllPrefixes(1) as $k) { $interWikis[$k[iw_wikiid]] = $k[iw_prefix];}; // Extract params from $request. if ( $request->getText( 'from' ) ) { @@ -119,13 +120,14 @@ $out->addHtml( '<div id="mw-globalusage-result">' ); foreach ( $query->getSingleImageResult() as $wiki => $result ) { + $interwiki = Interwiki::fetch($interWikis[$wiki]); $out->addHtml( '<h2>' . $this->msg( 'globalusage-on-wiki', - $targetName, WikiMap::getWikiName( $wiki ) )->parse() + $targetName, parse_url($interwiki->getURL(), PHP_URL_HOST) )->parse() . "</h2><ul>\n" ); foreach ( $result as $item ) { - $out->addHtml( "\t<li>" . self::formatItem( $item ) . "</li>\n" ); + $out->addHtml( "\t<li>" . self::formatItem( $item, $interwiki ) . "</li>\n" ); } $out->addHtml( "</ul>\n" ); } @@ -140,15 +142,14 @@ * @param $item array * @return String */ - public static function formatItem( $item ) { + public static function formatItem( $item, $interwiki ) { if ( !$item['namespace'] ) { $page = $item['title']; } else { $page = "{$item['namespace']}:{$item['title']}"; } - $link = WikiMap::makeForeignLink( $item['wiki'], $page, - str_replace( '_', ' ', $page ) ); + $link = Linker::makeExternalLink( $interwiki->getURL($page) , str_replace( '_', ' ', $page )); // Return only the title if no link can be constructed return $link === false ? $page : $link; } ----------------------------------------------
Updating GlobalUsage data
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Hello all, can someone here be so kind to give me a pointer to the mechanism that triggers the update of the data that is displayed by this extension? In the concrete example i try to find out why a lot of GlobalUsage data in WikiCommons is not up-to-date related to pages in German Wikisource and maybe others. (https://phabricator.wikimedia.org/T108799) I will be thankful for every hint. Aschroet (talk) 13:26, 12 August 2015 (UTC)
- It piggy-backs on MediaWiki's built-in LinksUpdate jobs, using the LinksUpdateComplete hook. Matma Rex (talk) 06:00, 12 November 2016 (UTC)
Gettign "Param pages required!"
Gettign "Param pages required!"
with
php extensions/GlobalUsage/refreshGlobalimagelinks.php Deletedaccount4567435 (talk) 09:06, 5 November 2016 (UTC)
How to generate links under File usage on other wikis session?
Hi all, after a long long period of hardworking we finally got the GlobalUsage work with two separate database across pacific ocean.
We got the "File usage on other wikis" part show as following. It is clear that some setting need to be set. (May be $wgConf?) Can anyone provide help on the linking part?
THX
The following other wikis use this file:
Usage on enmoegirl
*pagename1
Usage on zhmoegirl
*pagename2
..... Deletedaccount4567435 (talk) 13:51, 14 November 2016 (UTC)
- Yes, if links don't work, it means $wgConf isn't set correctly, and MediaWiki doesn't know what the $wgArticlePath and related variables are for the other wiki. Bawolff (talk) 18:24, 26 December 2017 (UTC)
- I should add, this extension also supports manual:Sites table as an alternative to $wgConf if you prefer that. Bawolff (talk) 18:57, 26 December 2017 (UTC)
- I have add the sites table through importSites.php.
- However after purge/runjob, no links generated. This table do exist in database, But its empty & and nothing using this table before importSites. I do saw extensions use "interwiki" table. Does the "sites" table still in use?
- <sites version="1.0">
- <site type="mediawiki">
- <globalid>enmoegirl</globalid>
- <localid type="interwiki">enmoegirl</localid>
- <localid type="language">en</localid>
- <group>moegirlpedia</group>
- <path type="link">https://en.moegirl.org/</path>
- <path type="page_path">https://en.moegirl.org/$1</path>
- <path type="file_path">https://en.moegirl.org/$1</path>
- <source>wikidata</source>
- </site>
- </sites> Deletedaccount4567435 (talk) 01:27, 1 January 2018 (UTC)
- After few hours of wait, the link shows up as it suppose to! Yeah!
- I guess problem caused by cache delay.
- Thank you!!!!! Bawolff! Deletedaccount4567435 (talk) 03:59, 1 January 2018 (UTC)
Global usage links not showing on master wiki
Hi all, I've got a wiki farm set up in several languages with file uploads centralized on the English version. GlobalUsage is enabled but I'm having the following issues:
- The global usage section shows on all wikis but the English one (where files actually live).
- In the other languages, the global usage section shows but file usage from the English wiki is missing.
I checked the globalimagelinks
table and the only entries where gil_wiki
corresponds to the English wiki are missing (wanted files). If I run refreshGlobalimagelinks.php --pages=existing,nonexisting
from an empty table, only those 'wanted files' are created.
Here are the relevant bits of my config for reference:
if ($wgLang != $availableLanguages[0]) {
$wgEnableUploads = false;
$wgUploadNavigationUrl = "/wiki/en/Special:Upload";
$wgUseSharedUploads = true;
$wgSharedUploadPath = '/wiki/images';
$wgSharedUploadDirectory = $IP . '/images';
$wgHashedSharedUploadDirectory = true;
$wgFetchCommonsDescriptions = true;
$wgSharedUploadDBname = $databasePrefix . $availableLanguages[0];
$wgSharedUploadDBprefix = 'wiki_';
$wgRepositoryBaseUrl = "https://mysite.com/wiki/en/File:";
}
(Here $wgLang
is the language code of the wiki and $availableLanguages[0]
is just en
for English. All I'm doing is setting up a shared uploads wiki for all languages but English.)
wfLoadExtension('GlobalUsage');
$wgGlobalUsageDatabase = $databasePrefix . $availableLanguages[0] . '-' . $wgDBprefix;
foreach ($availableLanguages as $availableLanguage) {
$wgConf->suffixes[] = $databasePrefix . $availableLanguage . '-' . $wgDBprefix;
$wgConf->settings["wgCanonicalServer"]["$databasePrefix$availableLanguage-$wgDBprefix"] = "https://mysite.com";
$wgConf->settings["wgArticlePath"]["$databasePrefix$availableLanguage-$wgDBprefix"] = "/wiki/$availableLanguage/$1";
}
(Here the loop on $availableLanguages
just sets up $wgConf
for each wiki.)
I have also tried to add a $wgLBFactoryConf
, but to no avail.
Any help on the matter would be greatly appreciated. Synonymshawfinch (talk) 14:07, 15 October 2018 (UTC)
Globalusage not show on File page when shared repo database like 'dbname-prefix'
If shared repo database contain a table prefix, $wgGlobalUsageDatabase should be dbname-prefix
. I found getDBname()
isn't contain the table prefix, so Globalusage not show on File page. I found getDomainId()
result is dbname-prefix
, but I don't know if it 's right use, and if my setting wrong in Globalusage.
The code in GlobalUsageImagePageHooks.php line118(Github):
$dbr->getDBname()!=$wgGlobalUsageDatabase
Sunwui (talk) 11:11, 25 August 2021 (UTC)