Problem/Motivation

Renaming folder via IMCE needs clear cache to render updated file link.

Steps to reproduce:

  1. create a folder via IMCE and upload a file in it (eg. /sites/default/files/news_attachments/test.pdf)
  2. create a node and select that file in a file field (eg. "attachments")
  3. via IMCE rename the folder of the file (eg. /sites/default/files/news_files/test.pdf)
  4. visit the node.

After renaming folder I continue to see the link of the file with the old path.
Clearing drupal cache solves the problem.

Proposed resolution

Maybe in src/Plugin/ImcePlugin/Rename.php@renameFolder() clear a specific cache table.

Thank you!

Comments

df_11 created an issue. See original summary.

sandeepsingh199’s picture

Assigned: Unassigned » sandeepsingh199
zulljin’s picture

Hi, checking this problem

df_11’s picture

I tried to add this after line 262 and it worked! It's fast, better than clearing all the caches.

$renderCache = \Drupal::service('cache.entity');
$renderCache->invalidateAll();

I don't know if it is the best solution, but maybe it is an idea :)

sandeepsingh199’s picture

Assigned: sandeepsingh199 » Unassigned
Status: Active » Needs review

@df_11, $renderCache = \Drupal::service('cache.entity'); $renderCache->invalidateAll(); is working fine, but if we have lots of files, images videos are their, it might be decrease the site performance. For quick fix we good to go. Marking this ticket to Needs Review.

zulljin’s picture

I guess better is clear cache by cache tag, it's optimal solution

zulljin’s picture

Status: Needs review » Needs work