Problem/Motivation
On our site, image styles using textimage are needing to be regenerated very frequently despite the image style not changing. We found that any time _any_ file is deleted from the site, that all derivatives using textimage are deleted.
Steps to reproduce
Prerequisites:
* Have the image module installed
* Have configured an image style using text image
1. Attempt to access the image style so that the derivative is created
2. Find the file on disk (i.e. private://textimage_store/cache/styles/style_name)
3. Delete any file entity from Drupal
Even though the generated image may be completely unrelated to the file that was deleted, the textimage image style folder will be deleted.
Proposed resolution
This is happening because the image module will call ImageStyle::flush()
when any file is deleted passing in every image style and the path of the file that was deleted. The intent is to clean up derivatives of the deleted file.
However, the textimage module's implementation of hook_image_style_flush
disregards the second parameter available ($path
) and assumes that any time the hook is invoked, that all images should be deleted.
The quickest fix here is to only flush the textimage image style if the $path
parameter in the hook is NULL (which is Drupal's way of indicating the entire image style should be flushed).
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A