Page MenuHomePhabricator

Exclude files used in other wikis from Special:UnusedFiles, by Extension:GlobalUsage
Closed, ResolvedPublic

Description

Extension:GlobalUsage could show files been used in other shared wikis.

However, Special:UnusedFiles keep showing all files not been used locally. Is it possible to exclude these file?

Example: https://commons.wikimedia.org/wiki/Special:UnusedFiles Showing https://commons.wikimedia.org/wiki/File:L%27eglijhe_di_T%C3%AEtindje.jpg in the list. But it was used in de.wikipedia.org/en.wikipedia.org/fr.wikipedia.org/nl.wikipedia.org.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

[Without committing to doing it] yes, it should be possible to make a special:globallyunusedfiles or something

Aklapper renamed this task from Is it possible to exclude files used in other wikis from Special:UnusedFiles, by Extension:GlobalUsage? to Exclude files used in other wikis from Special:UnusedFiles, by Extension:GlobalUsage.Dec 25 2017, 12:34 PM
Aklapper triaged this task as Lowest priority.

Ok. So I think this may be suitable as a Google code-in task.

[This is a slightly harder to task, you should have previously completed at least one MediaWiki programming task before attempting this one]

What you (the gci student) needs to do:

  • Have 2 wikis setup, one of which setup like "Commons" so it shares its files with a client wiki. They should be linked with Extension:GlobalUsage. Setting this up is probably the hardest part of the whole thing. If you're using vagrant, you may be able to use the "globalusage" role ( https://www.mediawiki.org/wiki/MediaWiki-Vagrant#Using_roles ). Otherwise see instructions at https://www.mediawiki.org/wiki/Extension:GlobalUsage
  • Take a look at includes/specials/Specialunusedimages.php in MediaWiki core. What we want to do is make a global version of this, that only outputs unused files if they are unused on all wikis. Sort of similar to how includes/SpecialGloballyWantedFiles.php (in GlobalUsage extension) is a global equivalent to includes/specials/Specialwantedfiles.php in MediaWiki core.
  • copy includes/specials/Specialunusedimages.php into the GlobalUsage extension
  • Change the getQueryInfo() so that it joins against the globalimagelinks table (see patches/GlobalUsage.sql in GlobalUsage extension for definiton of table) instead of the imagelinks. This involves changing references to imagelinks and changing references to fields starting with il_ to their equivelent in globalimagelinks (generally starting with gil_)
  • Ensure that the script will only run if the current wiki is in the same db as the globalimagelinks table ($wgGlobalUsageDatabase must either be the same as wfWikiId() or it must be false). You should check this condition in the isCacheable(), isListed(). You should output an error of some sort (e.g. throw a FatalError exception) in execute() method if this is not the shared repo. You should throw an Exception in getQueryInfo() if we are not on the shared repo wiki.
  • Change the class name to something else (e.g. GloballyWantedFiles)
  • Use a different message for the getPageHeader(). Add your new message to the i18n/en.json and i18n/qqq.json in extension.
  • Add the equivalent of the unusedimages message to the extension (Since your naming your special page something like Special:GloballyUnusedFiles, the message should probably be globallyunusedfiles)
  • Register the special page in extension.json and GlobalUsage.alias.php
    • Register in GlobalUsageHooks::onwgQueryPages() (includes/GlobalUsageHooks.php in GlobalUsage extension). This should only register the page as a query page if we are on the shared repository.
  • Test it all (You should test with both $wgMiserMode = false, as well as with $wgMiserMode = true where you need to use the maintienance/updateSpecialPages.php script)
nikitavbv subscribed.

This task seems to be interesting. I will work on this!

Change 401092 had a related patch set uploaded (by Phantom42; owner: Phantom42):
[mediawiki/extensions/GlobalUsage@master] Create Special:GloballyUnusedFiles

https://gerrit.wikimedia.org/r/401092

Have 2 wikis setup, one of which setup like "Commons" so it shares its files with a client wiki. They should be linked with Extension:GlobalUsage. Setting this up is probably the hardest part of the whole thing.

Yes, it wasn't easy. This was my first time making multiple wikis setup, but finally I managed to get it to work! I am really happy about getting this experience.

I followed your instruction, @Bawolff. Thank you so much for it! It provided all needed details and was really effective in guiding me.

Test it all (You should test with both $wgMiserMode = false, as well as with $wgMiserMode = true where you need to use the maintienance/updateSpecialPages.php script)

I tested this new special page as you said. Seems to work properly.

I uploaded a patch adding Special:GloballyUnusedFiles. Please tell if something needs changing / improving / adding, etc.

Thank you so much again!

Change 401092 merged by jenkins-bot:
[mediawiki/extensions/GlobalUsage@master] Create Special:GloballyUnusedFiles page

https://gerrit.wikimedia.org/r/401092

Bawolff added a project: User-notice.

Awesome looks good.

Cool! Thank you all & happy new year!

Thank you for reviewing and merging!

If there will be something to improve or change on this page in the future, please tell and I will do it!

Thank you all & happy new year!

Thank you too! Happy New Year!