Page MenuHomePhabricator

If rights exist, suggest automatic deletion of the source wiki file
Closed, ResolvedPublic8 Estimated Story Points

Description

Motivation
In case the user has the appropriate rights on the source wiki, it most of the time would make sense to delete the source wiki file right away. However, there are some cases where even users with appropriate rights would want to keep a local copy, e.g. when they want to add a "keep local copy" template.

Acceptance Criteria

  • If users have the right to delete files from the source wiki, change the "Source wiki info" section to say the following:

You have the rights to delete the file on the source wiki. If you want the FileImporter to delete the file in your name, select this option:

  • delete file on source wiki in my name
  • The checkbox is by default unchecked
  • If the user checks the checkbox, i.e. wants to have the source file deleted, delete the source file in the name of the user. The edit summary should say This file is now on Wikimedia Commons (moved with FileImporter).
    • If the move was successful, show the usual success message on the target wiki file
  • If the move was not successful, show the yellow error message, but with this message: The file has been successfully imported to <target wiki name>, but the file could not be deleted automatically on <source wiki name>. Please return to [[the original file]] and delete it manually. [original file is link to source wiki]

Notes

  • This should all work as similar as possible to the workflow when adding a template. The only difference we make is the default behavior of the checkbox, as deleting is a "harsher" step to take

Dev notes:

  • There would probably a check necessary for user rights

Storypoints: 8

Related Objects

Mentioned In
rEFLI831b8db30fcc: Expose less implementation details in RemoteApiActionExecutor
rEFLI44c6d509e9de: Rename executeUserRightsAction() to …Query()
T227358: Add a link to the imported file in the delete and edit summary
rEFLI6dc9273aee16: Replace hardcoded site name
rEFLIea35695ab4fb: Tests for automatic deletion status
rEFLI99fea68bbbd8: Tests for automatic deletion status
rEFLIe4f2fe1deca6: Offer automated deletion of the source wiki file
rEFLId4a1dc2df11e: Offer automated deletion of the source wiki file
rEFLI1a11d2a0e36f: Offer automated deletion of the source wiki file
rEFLI4a5fa59ed5a4: Offer automated deletion of the source wiki file
rEFLI7d41f20fa20e: Offer automated deletion of the source wiki file
rEFLIf7d18dec3b3c: Offer automated deletion of the source wiki file
rEFLI4dec78e2765f: [WIP] Offer automated deletion of the source wiki file
rEFLIc8ff3af96c82: [WIP] Offer automated deletion of the source wiki file
T227064: User notification when an automated source edit or deletion fails
T225617: Add the nowcommons template to the source wiki if requested
rEFLI38141420057c: [WIP] Offer automated deletion of the source wiki file
rEFLIac7bb0f8e97c: [WIP] Offer automated deletion of the source wiki file
rEFLI68794dfd3028: [WIP] Offer automated deletion of the source wiki file
rEFLI9c542fee4d8e: [WIP] Offer automated deletion of the source wiki file
rEFLI128c9ec3c917: [WIP] Offer automated deletion of the source wiki file
rEFLIe60b7a8ac4a7: [WIP] Offer automated deletion of the source wiki file
Mentioned Here
T225617: Add the nowcommons template to the source wiki if requested
T227358: Add a link to the imported file in the delete and edit summary
T226075: Improve showing of success message
T227064: User notification when an automated source edit or deletion fails

Event Timeline

Lea_WMDE set the point value for this task to 8.

It's pretty clear from the description, but I want to double-check that we're replacing the normal "add template" checkbox with this delete checkbox when applicable, we never show both, correct?

Change 520005 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/FileImporter@master] [WIP] Offer automated deletion of the source wiki file

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

@Lea_WMDE If we fail to make the source wiki deletion, to be consistent with the "add template" feature we will:

  • Show a green success box at the top of the new target file page.
  • Show a yellow warning box with text saying the automated deletion failed.

Is this alright?

Another implementation detail that I'll say out loud: if deletion fails, we'll go straight to the legacy fallback where we simply print out the instructions for editing manually. In the future, we might try the remote edit as the first fallback, then the manual editing instructions as a second fallback...

@Lea_WMDE If we fail to make the source wiki deletion, to be consistent with the "add template" feature we will:

  • Show a green success box at the top of the new target file page.
  • Show a yellow warning box with text saying the automated deletion failed.

Is this alright?

Thanks for double checking, I was not actually expecting two boxes, but one: Green if all was fine, and yellow if the move worked alright but the deletion did not. Do we have two boxes at the same time for "add template" right now that would be shown at the same time?

Thanks for double checking, I was not actually expecting two boxes, but one: Green if all was fine, and yellow if the move worked alright but the deletion did not. Do we have two boxes at the same time for "add template" right now that would be shown at the same time?

Yes, this is at least temporarily how the code is written, so let me paste some screenshots in the relevant tasks in order to start a discussion...

The code is ready for review, just waiting to resolve T227064, and to write a few more tests once we rebase on top of the main testing patch.

Change 520222 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/FileImporter@master] Tests for automatic deletion status

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

Change 520234 had a related patch set uploaded (by Awight; owner: Awight):
[operations/mediawiki-config@master] Enable experimental FileImporter features on labs

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

Change 520005 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Offer automated deletion of the source wiki file

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

I think fileimporter-delete-summary could be improved. (I can split this to a different task if needed.)

Current
"fileimporter-delete-summary": "This file is now on Wikimedia Commons (moved with FileImporter).",
Desired
"fileimporter-delete-summary": "This file is now on $site as $file (moved with FileImporter).",

where $site would be Wikimedia Commons for the WMF cluster and $file would be a link to the imported file, e.g. [[:c:File:Example.png]] for the WMF cluster.

It looks like fileimporter-cleanup-summary accomplishes the site part, but both could use a link to the file. The delete summary having the file link is more important than the cleanup summary having it since the cleanup edit will contain the file name.

Having a link to the imported file is important to show where the file ended up since the name may change during the import and/or the file may get deleted.

Change 520222 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Tests for automatic deletion status

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

Current
"fileimporter-delete-summary": "This file is now on Wikimedia Commons (moved with FileImporter).",

Thanks, I'll swap {{SITENAME}} for "Wikimedia Commons".

Having a link to the imported file is important to show where the file ended up since the name may change during the import and/or the file may get deleted.

Our success page changed quite a bit due to T226075: Improve showing of success message, actually. Would you mind trying an import on the beta cluster, e.g. https://commons.wikimedia.beta.wmflabs.org/wiki/Special:ImportFile?clientUrl=https://en.wikipedia.beta.wmflabs.org/wiki/File:MO-WMF.jpg so you can see the new workflow? The biggest difference is that the user actually sees the success message embedded in the target file page (on Commons), so I'm not sure we need to present an additional link to the target file.

Change 520393 had a related patch set uploaded (by Awight; owner: Awight):
[mediawiki/extensions/FileImporter@master] Replace hardcoded site name

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

Change 520393 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Replace hardcoded site name

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

Change 520234 merged by jenkins-bot:
[operations/mediawiki-config@master] Enable experimental FileImporter features on labs

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

This is ready to demo on beta commons, but you'll need an account with rights to make the deletion on the beta source wiki.

I can confirm the deletion works! However, I now used up my test file and cannot test that it doesn't always delete. I'll check tomorrow with a new file

Lea_WMDE moved this task from Demo to Done on the WMDE-QWERTY-Sprint-2019-06-26 board.

ok done already :)

Current
"fileimporter-delete-summary": "This file is now on Wikimedia Commons (moved with FileImporter).",

Thanks, I'll swap {{SITENAME}} for "Wikimedia Commons".

Thanks

Having a link to the imported file is important to show where the file ended up since the name may change during the import and/or the file may get deleted.

Our success page changed quite a bit due to T226075: Improve showing of success message, actually. Would you mind trying an import on the beta cluster, e.g. https://commons.wikimedia.beta.wmflabs.org/wiki/Special:ImportFile?clientUrl=https://en.wikipedia.beta.wmflabs.org/wiki/File:MO-WMF.jpg so you can see the new workflow? The biggest difference is that the user actually sees the success message embedded in the target file page (on Commons), so I'm not sure we need to present an additional link to the target file.

The link isn't for the success message but for the deletion log on the source wiki. The importer will know where the file ended up, but others cannot easily find out if the file was imported under a different name or when it is deleted after being imported.

Say File:Generic name.jpg was being used in My cool article. An admin imports the file to File:Descriptive name.jpg and deletes the original. If the admin doesn't update the file name in My cool article, it would be good for others to be able to know the new name (to be able to fix the article without having to ask the importer or sift through the importer's imports on Commons to find the new file name). Even when the file name gets updated by the importer, someone reviewing edits to the article may want to check that the image is the same one that was originally there.

I have an account (JJMC89) on the beta cluster, but I don't have delete rights.

Current
"fileimporter-delete-summary": "This file is now on Wikimedia Commons (moved with FileImporter).",

...

Having a link to the imported file is important to show where the file ended up since the name may change during the import and/or the file may get deleted.

...

The link isn't for the success message but for the deletion log on the source wiki. The importer will know where the file ended up, but others cannot easily find out if the file was imported under a different name or when it is deleted after being imported.

Say File:Generic name.jpg was being used in My cool article. An admin imports the file to File:Descriptive name.jpg and deletes the original. If the admin doesn't update the file name in My cool article, it would be good for others to be able to know the new name (to be able to fix the article without having to ask the importer or sift through the importer's imports on Commons to find the new file name). Even when the file name gets updated by the importer, someone reviewing edits to the article may want to check that the image is the same one that was originally there.

Thanks for the explanation, I agree with this point. Apologies for my misunderstanding earlier!

@JStrodt_WMDE @Lea_WMDE Please refer to the above discussion, we should probably add the target file URL to our source wiki edit summaries?

We do the same in the reverse direction for the edit summary of importing to the target wiki, setting a good precedent for including the URL: https://commons.wikimedia.beta.wmflabs.org/w/index.php?title=File:Bluesq.png&diff=prev&oldid=108316

Just a minor point, when we make the automated source wiki edit to add the {{NowCommons}} template, this includes a parameter which points to the newly created target file. Would you say it's still worthwhile to include the URL in the edit summary, in this case?

I have an account (JJMC89) on the beta cluster, but I don't have delete rights.

Thanks for entertaining the idea! You could ask for admin privileges for a beta host via Phabricator, or ask one of the current admins (e.g. on enwiki-beta) to test the feature. I think I can help with this request if you'd like.

@awight Sounds good to me, but the decision is up to @Lea_WMDE.

@JJMC89 thanks for the feedback! It makes complete sense for me, let's add the info where exactly to find the file to the edit summary! Even though this info might be visible on the file page, especially when considering logs it is much more handy to be able to check everything from the edit summary and not having to switch back and forth between file page and log.
I open the ticket to indicate that there is an open task, but I am (even more) happy if you close it again and create a new ticket for the sugggested change (it's just time that makes me not do it now)

Change 523661 had a related patch set uploaded (by Awight; owner: Awight):
[operations/mediawiki-config@master] Enable FileImporter source wiki edit and delete

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

Planning to enable in production on Monday, July 22nd.

Change 523661 merged by jenkins-bot:
[operations/mediawiki-config@master] Enable FileImporter source wiki edit and delete

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

Mentioned in SAL (#wikimedia-operations) [2019-07-22T11:13:05Z] <awight@deploy1001> Synchronized wmf-config/CommonSettings.php: SWAT: [[gerrit:523661|Enable FileImporter source wiki edit and delete (T225617, T226532)]] (duration: 00m 56s)

Mentioned in SAL (#wikimedia-operations) [2019-07-22T11:14:36Z] <awight@deploy1001> Synchronized wmf-config/CommonSettings-labs.php: SWAT: [[gerrit:523661|Enable FileImporter source wiki edit and delete, (remove labs customizations) (T225617, T226532)]] (duration: 00m 54s)

Change 599029 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/FileImporter@master] Rename executeUserRightsAction() to …Query()

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

Change 599046 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/FileImporter@master] Expose less implementation details in RemoteApiActionExecutor

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

Change 599029 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Rename executeUserRightsAction() to …Query()

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

Change 599046 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Expose less implementation details in RemoteApiActionExecutor

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