Page MenuHomePhabricator

Parse the file info wikitext to forbid files with a wrong licence
Closed, ResolvedPublic

Description

Motivation
The CommonsHelper's config files tell us which categories and templates should prohibit a file move. We want to find out if one of the forbidden categories and templates exist in the most current version of the file page, to be able to disallow the move.

Acceptance Criteria

  • If the most current version of the file move candidate contains one of the categories or templates as defined in T194129, disallow the file move.
  • The user should be redirected to the error page. The message should be as defined in T189570 under "wrong licence":

The file cannot be imported, because it is marked as <template name/ category name>. <The target wiki name> does not allow such files.

  • If there is no forbidden template or category, continue with the file move without any further comment.
  • This happens before we enter the file preview page.

Notes

  • Investigation and proof of concept was done in T193622. We should get the lists of templates and categories from the API of the source wiki. The above ticket contains a proof of concept patch

Related Objects

Event Timeline

Lea_WMDE set the point value for this task to 3.

Change 436291 had a related patch set uploaded (by Andrew-WMDE; owner: Andrew-WMDE):
[mediawiki/extensions/FileImporter@master] Forbid the import of a file that contains a blocked Category/Template

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

Change 437248 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/FileImporter@master] Add test for WikiTextContentValidator

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

Change 437246 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/FileImporter@master] Make WikiTextConversions comparisons case-insensitive

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

Change 436291 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Forbid the import of a file that contains a blocked Category/Template

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

Change 437248 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Add test for WikiTextContentValidator

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

Change 437246 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Make WikiTextConversions comparisons case-insensitive

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

When I use https://mwfileimport.wmflabs.org/wiki/index.php/Special:ImportFile with https://en.wikipedia.org/wiki/File:2018_FIBA_Under-18_Americas_Championship.png I get

The configuration file for your wiki (https://meta.wikimedia.org/wiki/CommonsHelper2/Data_en.wikipedia) does not contain enough info about <Templates> to know if this file can be put on Commons.

So https://meta.wikimedia.org/wiki/CommonsHelper2/Data_en.wikipedia is missing a headline for templates so we stop the process and show that error. I just want to make sure if this is what we want. Enforcing the rough structure even when no Templates are needed/wanted to be configured.

@thiemowmde @Lea_WMDE

Ok I just realized that this error is due to T194502 - we might want to change that, since en.wp seems to only rely on good categories not templates.

The file https://meta.wikimedia.org/wiki/CommonsHelper2/Data_en.wikipedia was incomplete because of an edit by an anonymous user that almost blanked the page. I restored the previous version.

I think we should decide if we want some of the sections we currently expect in each config file to be optional. For example, I think the two "Bad" sections need to be mandatory, while the "Good" sections can be optional. That would be convenient. On the other hand, it might be inconsistent and confusing. Maybe it's better to have all sections mandatory.

Thanks for fixing the page @thiemowmde! For now, let's stick to the decided behavior, and in the process of people using the file we will see if it makes sense to loosen the restrictions.

I got a nice error message, only the wording is different from what it says in the ticket, instead it says The file cannot be imported, because it is not marked with one of the required licences. Please add one of these templates, if appropriate.

I got a nice error message, only the wording is different from what it says in the ticket, instead it says The file cannot be imported, because it is not marked with one of the required licences. Please add one of these templates, if appropriate.

I assume when you get this error message the error is not due to this ticket but due to T194502 :-)

good point :) Can you point me to a file that actually triggers this error?

That could be a bit tricky, because it means I have to find a file, that has a template marking it as "good" but also one marking it as "bad" ... if I get how these checks work now ... ^^

Vvjjkkii renamed this task from Parse the file info wikitext to forbid files with a wrong licence to redaaaaaaa.Jul 1 2018, 1:11 AM
Vvjjkkii removed Andrew-WMDE as the assignee of this task.
Vvjjkkii raised the priority of this task from Medium to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed the point value for this task.
Vvjjkkii edited subscribers, added: Andrew-WMDE; removed: gerritbot, Aklapper.
Bodhisattwa renamed this task from redaaaaaaa to Parse the file info wikitext to forbid files with a wrong licence.Jul 1 2018, 2:00 PM
Bodhisattwa assigned this task to Andrew-WMDE.
Bodhisattwa lowered the priority of this task from High to Medium.
Bodhisattwa updated the task description. (Show Details)
Bodhisattwa added subscribers: gerritbot, Aklapper.

@Lea_WMDE Can you please recheck if this is done from your perspective?