Problem/Motivation

As discussed in #3164519: Drupal 8 cannot delete image, it show "XX.JPG is in use by another application", it is not possible to delete an image if it is being used by drupal. I had a look in the code and I see that
$ignore_usage = $fm->getConf('ignore_usage', FALSE); was already implemented but the feature was not totally ready to be used.

Proposed resolution

Finish the implementation, so site admins and site builders can manage if a user will be able to ignore the file usage when deleting it.

Comments

paulocs created an issue. See original summary.

paulocs’s picture

Assigned: paulocs » Unassigned
Status: Active » Needs review
StatusFileSize
new2.09 KB

Follow a patch.

Cheers, Paulo.

paulocs’s picture

Assigned: Unassigned » paulocs
Status: Needs review » Needs work

Patch needs re-roll.

I'll do it.

paulocs’s picture

paulocs’s picture

Status: Needs work » Needs review
thalles’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!
Thanks @paulocs!

  • thalles committed c54afc8 on 8.x-2.x authored by paulocs
    Issue #3166956 by paulocs: Enable to delete file even if drupal is using...
thalles’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

embeau’s picture

I was expecting this change to be included in the latest release (8.x-2.3), but it wasn't.
Tested with the dev branch and it works great! However, we do not want to use the dev branch on our prod site and I can't apply this patch to 2.2 or 2.3.
Any suggestions?
Thanks!

sxs551’s picture

Agree with #11. Will this patch be included as part of a stable release anytime soon?

ufku’s picture

It's in https://www.drupal.org/project/imce/releases/8.x-2.x-dev and will be in the next stable release.

namita21’s picture

Unable to apply the patch for IMCE 2.3v, is there another workaround for this issue.

dqd’s picture

Title: Enable to delete file even if drupal is using it. » Enable to delete file even if drupal is using it. (NOT IMPLEMENTED YET)
Version: 8.x-2.x-dev » 3.x-dev
Assigned: paulocs » Unassigned

Hm, seems that this got lost in the later releases v2 and v3, so this actually should be re-opened. And re-implemented? Or some documentary or statement here should explain where to find this option or why it has not been implemented (sometimes such things happen for good reasons but should be documented somehwere).

dqd’s picture

Apart from #15, another thing I worry about is:

+    $conf['operation_settings']['ignore_usage'] = [
+      '#type' => 'checkbox',
+      '#title' => $this->t('Ignore the file usage when deleting it.'),
+      '#default_value' => $imce_profile->getConf('ignore_usage'),
+      '#description' => $this->t('If it is checked it will be able to delete a file even if it is being used somewhere else. Pay attation if you really wanna to enable it.'),
+      '#parents' => ['conf', 'ignore_usage'],
+    ];

Is just an attempt to override the default config which disallows ignoring usage. But: I am not sure if this is enough to solve that underlying problem and it can possibly break the site if the image has other relations on the site which are not known yet. I wonder if this would cause things like, for example, keeping orphaned revision data of this image in the database, which could become a problem later. I wonder if this is enough to just note "pay attention" or if it rather should be seomthing more ringing like: "Be warned! This setting should only be used temporarely for chirurgical purposes, where an image won't allow to be deleted and you are sure it has definitely no usage or connection no more in the system. Make sure revisions are turned off for this image if it still exist in the content file or media overviews. Standard setting should be OFF here (recommended)."