Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When saving the block configuration with a non-default Theme hook suggestion, the following notice is displayed:
Notice: Undefined index: exists in Drupal\Core\Render\Element\MachineName::validateMachineName() (line 245 of core/lib/Drupal/Core/Render/Element/MachineName.php).
Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in Drupal\Core\Render\Element\MachineName::validateMachineName() (line 246 of core/lib/Drupal/Core/Render/Element/MachineName.php).
To reproduce, add a menu block with (menu__)menu__level1
as theme hook suggestion.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2799991-4-an-exists-method-implementation.patch | 940 bytes | Chalk |
Comments
Comment #2
Sutharsan CreditAttribution: Sutharsan commentedTagging as easy to fix.
Comment #3
Chalk CreditAttribution: Chalk at DrupalSquad commentedI've reproduced this issue. I will try fix it.
Comment #4
Chalk CreditAttribution: Chalk at DrupalSquad commentedHi, @Sutharsan.
The problem is that a block plugin doesn't have an implementation of 'exists' function.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element!Ma...
As I understand, there is no need to validate theme hook suggestions by unique value. If I'm wrong - let me know and I will update the patch.
Comment #5
Sutharsan CreditAttribution: Sutharsan commentedPatch fixes the problem. Patch code is good. Doc with ::suggestionExists() answere my wtf question. Patch applies to latest dev. ::suggestionExists() must be public because it is called by MachineName::validateMachineName().
menu_block does not have unit tests :( so I assume it is Ok to RTBC a patch without tests. But correct me if I'm wrong.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedHi, I've tested this patch and it works. No longer getting the notice displaying when using a non-default theme hook suggestion. Could we get this merged in? Thanks, Jackie
Comment #7
iryston CreditAttribution: iryston as a volunteer commentedPatch #4 fixes the problem. Thanks!
Comment #8
joelpittetThank you for resolving that @Chalk and @Sutharsan