- Issue created by @gorkagr
- Merge request !5858Issue #3401971 by fjgarlin: Test-only job shouldn't require constant rebases... โ (Closed) created by gorkagr
- Merge request !5861Issue #3409413 by gorkagr: Update FieldTypeCategory to avoid TypeError if description is missing in annotations โ (Open) created by gorkagr
- First commit to issue fork.
- Status changed to Needs work
11 months ago 2:29pm 18 December 2023 - ๐ฌ๐งUnited Kingdom longwave UK
Coding standards checker doesn't like it though:
19 | WARNING | Do not pass empty strings to t()
- ๐ง๐ชBelgium gorkagr
Hi @longwave
Having only
description = "text"
in the annotation causes:TypeError: Drupal\Core\Field\FieldTypeCategory::getDescription(): Return value must be of type Drupal\Core\StringTranslation\TranslatableMarkup, string returned in Drupal\Core\Field\FieldTypeCategory->getDescription() (line 26 of core/lib/Drupal/Core/Field/FieldTypeCategory.php).
so yes, there is an issue with that part too
- ๐ง๐ชBelgium gorkagr
Something such as
/** * {@inheritdoc} */ public function __construct(array $configuration, string $plugin_id, array $plugin_definition) { $plugin_id = $configuration['unique_identifier']; $plugin_definition = [ 'label' => $configuration['label'], 'description' => (isset($configuration['description']) ? ($configuration['description'] instanceof TranslatableMarkup ? $configuration['description'] : new TranslatableMarkup($configuration['description'])) : new TranslatableMarkup('')), 'weight' => $configuration['weight'] ?? 0, ] + $plugin_definition; parent::__construct($configuration, $plugin_id, $plugin_definition); }
can cover the empty case, the string only and the use of @translation in the annotation.
- ๐ฌ๐งUnited Kingdom longwave UK
'description' => (isset($configuration['description']) ? ($configuration['description'] instanceof TranslatableMarkup ? $configuration['description'] : new TranslatableMarkup($configuration['description']))
I don't think this is the right solution either, as we shouldn't pass arbitrary strings to TranslatableMarkup (coding standards checker may also complain about this). I think a better solution might be to relax the types in places so we accept either TranslatableMarkup or string.
- Status changed to Needs review
11 months ago 5:22pm 18 December 2023 - ๐ซ๐ฎFinland lauriii Finland
Changed the approach so that it doesn't require an empty translatable string
- ๐ง๐ชBelgium gorkagr
Hi @lauriii
Applied the last patch. It works with and without the @traslation in the description and also with plugins without the description
Thnks for the patch :)
- Status changed to RTBC
11 months ago 9:07pm 18 December 2023 - ๐จ๐ดColombia Freddy Rodriguez Bogotรก
+1 works perfect.
In this case, this bug limits the addition of new fields of any content type in D10.2. Should be considered critical?
-
longwave โ
committed 9dddb680 on 10.2.x
Issue #3409413 by gorkagr, lauriii, longwave: Error TypeError: Drupal\...
-
longwave โ
committed 9dddb680 on 10.2.x
-
longwave โ
committed 19f5bdd1 on 11.x
Issue #3409413 by gorkagr, lauriii, longwave: Error TypeError: Drupal\...
-
longwave โ
committed 19f5bdd1 on 11.x
- Status changed to Fixed
11 months ago 10:05am 20 December 2023 - ๐ฌ๐งUnited Kingdom longwave UK
As per the priority criteria this is still major and not critical, I classify this as "causes a significant admin- or developer-facing bug with no workaround" but there is no data loss and the site is still usable apart from this.
Committed and pushed 19f5bdd1e3 to 11.x and 9dddb68024 to 10.2.x. Thanks!
- ๐บ๐ธUnited States keiserjb
Thanks for getting this fix up on here. There are lots of modules that don't include a description in the annotations. This patch does fix things. I couldn't add fields on multiple sites and now I can.
Automatically closed - issue fixed for 2 weeks with no activity.