Problem/Motivation
I'm using a module which provides a block and specifically needs a unique ID in the render array.
Proposed resolution
Provide an ID based on the block plugin ID and a MD5 sum of the configuration variable.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3161956-9.patch | 500 bytes | gchauhan |
| #3 | 3161956-1.patch | 453 bytes | tripox |
Comments
Comment #2
chi commentedComment #3
tripox commentedComment #4
tripox commentedComment #5
chi commentedWhat is the point of having "md5(serialize($configuration))"? It does not make the ID unique.
Comment #6
tripox commentedYou're right, I was thinking it'd be unique. Do you have any suggestions?
If so, I will gladly update the patch. :)
Comment #7
chi commentedHere is how it is handled in 3.x branch
https://git.drupalcode.org/project/twig_tweak/-/blob/3.0.0-rc1/src/View/...
By default block plugin ID is used to create HTML ID, but users are free to pass custom ID through arguments.
Comment #8
gchauhan commentedComment #9
gchauhan commentedHi @Chi this is the patch as per your suggestions.
Thanks!
Comment #10
gchauhan commentedComment #12
chi commentedThank you.
Comment #13
kaipipek commentedThis change breaks our site. Error message in the log:
The code in the mentioned dexp_block_settings.module file is:
Comment #14
chi commented@kaipipek, that looks similar to #3174903: Error: Call to a member function getRegion() on null in hook_theme_suggestions_block_alter().
Comment #15
kaipipek commentedIs there a fix planned or do you expect everyone else to fix their (often 3rd party) modules or stop using Twig Tweak?
Comment #16
chi commentedNo any fixes planned yet.
Comment #17
kaipipek commentedFor instance I personally have no idea how to fix this and I believe the affected module is not maintained anymore. I am suprised that you were not able to implement this new feature with backwards compatibility because there is no benefit from it for many old users.
Comment #18
chi commentedIf this caused a BC break I may revert the commit. At any rate it needs clear steps to reproduce the issue (preferably with failing test).
Comment #19
kaipipek commentedI can give you the detailed error log or we can have a short Skype/Teams call if that helps?
Comment #20
chi commentedThat's why issue queues exist on drupal.org. Just submit a new issue and provide exact steps to reproduce the problem on fresh Drupal installation.
https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquett...
Comment #21
chi commented@kaipipek #3174903: Error: Call to a member function getRegion() on null in hook_theme_suggestions_block_alter() has been just fixed. That may have resolved your issue too.
Comment #22
kaipipek commentedYes, the issue has been resolved. Excellent, thanks!