- Issue created by @fago
- π¦πΉAustria fago Vienna
Traced it down to be caused by π hook_image_style_flush doesn't get the $path passed to Drupal\image\Entity\ImageStyle::flush() method Fixed - before this change it was returning earlier in the method, thus never clearing theme registry when $path is set
- π¦πΉAustria fago Vienna
After some more research I found out the change was introduced by π hook_image_style_flush doesn't get the $path passed to Drupal\image\Entity\ImageStyle::flush() method Fixed in Drupal 10.2 - a new optional $path parameter was added to image style flush hook. While doing so the flush() method was re-factory wrongly such that the theme registry + cache tags are cleared also when $path is given.
So both should be fixed. We've reproduced that addressing this and the related bug π With 10.2 image styles might get wrongly flushed Active solves the issues and brings those slow file upload requests down from ~25seconds to normal <2seconds.
Related change record: https://www.drupal.org/node/3373248 β
- π·πΈSerbia petar_basic
Here is a patch to prevent flushing theme registry + cache tags if the path is provided.
- Status changed to Needs review
8 months ago 2:53pm 10 April 2024 - Merge request !7420Issue #3439981 by petar_basic, fago: Do not flush theme registry when uploading a file to media library. β (Open) created by fago
- π¦πΉAustria fago Vienna
Converted the patch into a MR so the pipeline runs and slightly improved the comment.
- Status changed to Needs work
8 months ago 3:04pm 10 April 2024 The Needs Review Queue Bot β tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request β . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
- π¦πΊAustralia acbramley
This should be rebased against 11.x first, also we don't need to include usernames in the MR titles. Hiding the patch.
And of course, we need tests :)
- π¦πΉAustria fago Vienna
Not sure what a test would do here? Maybe a unit test making sure the theme-registry service is not invoked when we call $imageStyle->flush($path);
- π¦πΊAustralia acbramley
@fago yeah having a look at what the theme registry reset does, I guess you could check that those specific cids still exist in cache. Ideally we'd have a test cache tag invalidator that could record the tags invalidated and we could assert things weren't invalidated but I can't see anything like that in core atm.
- First commit to issue fork.
- Merge request !7661Issue #3439981: Add unit test to check the theme registry is not reset when an... β (Open) created by ericgsmith
- π³πΏNew Zealand ericgsmith
ericgsmith β changed the visibility of the branch 3439981-uploading-a-file to hidden.
- Status changed to Needs review
8 months ago 4:09am 23 April 2024 - π³πΏNew Zealand ericgsmith
Added a new test method to the existing Image Style unit test to check that the registry and cache invalidation is not called if flush is called with a path. Checking the number of invocations seemed simpler than trying to dig through cache ids.
Hid the original MR - I see now according to https://www.drupal.org/docs/develop/git/using-gitlab-to-contribute-to-dr... β I should have pinged you to update it the MR - anyway, no open discussions on the original so hopefully all good.
- Status changed to RTBC
8 months ago 8:18pm 23 April 2024 - π¬π§United Kingdom catch
, I guess you could check that those specific cids still exist in cache. Ideally we'd have a test cache tag invalidator that could record the tags invalidated and we could assert things weren't invalidated but I can't see anything like that in core atm.
It's possible to assert the number of calls to cache tag invalidation in performance tests - would that be enough to produce a test that fails without the fix?
- π¬π§United Kingdom alexpott πͺπΊπ
I think the test coverage we have here is good enough for a pretty important bug fix. Sorry about committing the issue that caused the regression.
Committed and pushed 7b24d54842 to 11.x and 7546eb2a72 to 10.3.x and 02b8bc5462 to 10.2.x. Thanks!
-
alexpott β
committed 02b8bc54 on 10.2.x
Issue #3439981 by fago, ericgsmith, petar_basic, acbramley: Uploading a...
-
alexpott β
committed 02b8bc54 on 10.2.x
-
alexpott β
committed 7546eb2a on 10.3.x
Issue #3439981 by fago, ericgsmith, petar_basic, acbramley: Uploading a...
-
alexpott β
committed 7546eb2a on 10.3.x
- Status changed to Fixed
8 months ago 12:37am 24 April 2024 -
alexpott β
committed 7b24d548 on 11.x
Issue #3439981 by fago, ericgsmith, petar_basic, acbramley: Uploading a...
-
alexpott β
committed 7b24d548 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.