Comparison of style effect in image_features_revert() might never be equal

Created on 5 March 2021, about 4 years ago
Updated 7 September 2023, over 1 year ago

Problem/Motivation

In image_features_revert() it does not appear that the comparison of effects introduced in #2148453: Image styles do not revert properly can ever be equal. The effect loaded from code does not contain effect callbacks, presumably they were removed in #2308801: Export less data for image effects (within image styles) whereas the effect callbacks are present when loading the style using image_style_load(). So style effect array is never equal between the two.

The consequence of this is that it appears image styles in code are always reverted and flushed regardless as to whether they have changed our not. Flushing all image styles can cause broken images on larger sites especially if you are using picture module and images with sizes, as there appears to be a core issue preventing image styles from being created simultaneously, probably similar to the issue described in #3172863: Random "Failed to create style directory" on high concurrency and fresh styles/ directory for Drupal 8+.

Steps to reproduce

  • Have an enabled module with some images styles in code
  • Have some generated image styles in files directory
  • Put debugging of choice on in image_features_revert()
  • Ensure module image styles are in default state: drush fd [module] should return feature is in default state
  • Force revert drush fr --force [module].image and debug image_features_revert() notice the in code style effect contains no callbacks whereas the loaded style does.
  • Check files directory image styles, they will have been removed if effect comparison failed

Proposed resolution

Based on the work done for #2308801: Export less data for image effects (within image styles) the loaded image style could be passed through _image_features_style_sanitize() to make it comparable with the image style in code.

🐛 Bug report
Status

Needs review

Version

2.11

Component

Image Styles

Created by

🇺🇸United States lwalley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany ronino

    image_features_revert() took hours lately when deploying to the production server, deleting tons of image derivatives from S3 even though no image style had changed. This fixed it for me. This is great, thanks!

Production build 0.71.5 2024