- Issue created by @danflanagan8
- Status changed to Needs review
almost 2 years ago 3:34pm 23 March 2023 - πΊπΈUnited States danflanagan8 St. Louis, US
Here's a patch that refactors the kernel tests AND adds a tiny bit of new test coverage that ends up exposing a bug! Yay! The new test cases are token-less cases for when the token module is enabled. That's where the bug creeps in. Having a data provider makes adding cases soooo much easier.
- πΊπΈUnited States danflanagan8 St. Louis, US
Ah, darnit. My patch included the fix:
+++ b/src/Plugin/Field/FieldFormatter/FileDownloadLink.php @@ -327,8 +328,9 @@ class FileDownloadLink extends FileFormatterBase implements ContainerFactoryPlug - // Next line is important. See https://www.drupal.org/node/2528662. - $bubbleable_metadata->applyTo($elements[$delta]); + // Apply cacheability of tokens to render array. + $bubbleable_metadata->merge(CacheableMetadata::createFromRenderArray($elements[$delta])) + ->applyTo($elements[$delta]);
I was previously overwriting the existing cacheable metadata rather than adding to it. Now it's fixed.
-
danflanagan8 β
committed c6750624 on 2.0.x
Issue #3349706 by danflanagan8: Refactor file_download_link Kernel tests
-
danflanagan8 β
committed c6750624 on 2.0.x
- Status changed to Fixed
almost 2 years ago 3:54pm 23 March 2023 Automatically closed - issue fixed for 2 weeks with no activity.