Closed (fixed)
Project:
Gutenberg
Version:
3.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Jun 2024 at 08:08 UTC
Updated:
20 Jul 2024 at 15:49 UTC
Jump to comment: Most recent
It seems that the $block_attributes array does not contain the className key in certain cases, such as when using a custom Drupal Views block
Using bad theming I assume and using custom drupal views block, I get:
Drupal\gutenberg\BlockProcessor\DrupalBlockProcessor->processBlock() (line 93 of modules/contrib/gutenberg/src/BlockProcessor/DrupalBlockProcessor.php).
modify the code to check for the existence of the key before accessing it.
// Add extra CSS classes if available.
if ($block_attributes['className']) {
$extra_classes = preg_split('/\s+/', $block_attributes['className']);
foreach ($extra_classes as $class) {
if (!empty($class)) {
$render['content']['#attributes']['class'][] = $class;
}
}
}Review and merge
None
None
None
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
doxigo commentedComment #4
doxigo commentedComment #5
vegardjo commentedThis is sadly a regression from #3421059: Render custom classes for dynamic blocks, also present in 2.9, Doxigos (👋) fix should do it.
Comment #6
vegardjo commentedTested on 2.9 using this as a patch file: https://git.drupalcode.org/issue/gutenberg-3452390/-/commit/6f173ec402ea... and it solves the problem.
Comment #7
doxigo commentedHey Vegard 😍 long time no see, thanks for the review
Comment #8
dave kopecekI can confirm that #6 works for me as well.
Comment #11
marcofernandes commentedBackported to 8.x-2.x. Thank you!
Comment #12
doxigo commentedHey Marco, this seems to be merged into
3.xand we apparently also have a3.0.xwhich is not the default branch but is the tagged branch in the releases. so I assume we need to re-apply the patch to3.0.xand also change the default branch from3.xto3.0.xOpened the issue again
Comment #14
marcofernandes commented@doxigo Yeah, unfortunately d.o is a bit strict with branches naming/versioning. The idea of having 3.x branch was to avoid managing minor versions. I merged 3.x into 3.0.x and have set 3.0.x back to default.
Comment #15
doxigo commentedLovely, thanks
Comment #16
eiriksmSeems like something we should create a new release for? Not pretty to have these notices on a stable release I think.
Also, the fact that we have it shows we are missing test coverage. Can we create a follow up issue for adding test coverage here?
Comment #17
szeidler commentedIdeally we would bundle the three issues in a new release, which all could break Gutenberg or parts of it, because of warnings or errors.