Skip to content
Snippets Groups Projects
Verified Commit 9dddb680 authored by Dave Long's avatar Dave Long
Browse files

Issue #3409413 by gorkagr, lauriii, longwave: Error TypeError:...

Issue #3409413 by gorkagr, lauriii, longwave: Error TypeError: Drupal\Core\Field\FieldTypeCategory::getDescription() if a FieldType has 'description' missing in its annotation

(cherry picked from commit 19f5bdd1)
parent 571aeb51
No related branches found
No related tags found
16 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument,!6119Issue #3405704 by Spokje, longwave: symfony/psr-http-message-bridge major version bump,!5950Issue #3403653 by alexpott, longwave: Incorporate improvements to how contrib runs PHPStan to core
Pipeline #66219 passed with warnings
Pipeline: drupal

#66223

    ......@@ -13,7 +13,7 @@ class FallbackFieldTypeCategory extends FieldTypeCategory {
    public function __construct(array $configuration, string $plugin_id, array $plugin_definition) {
    $plugin_id = $configuration['unique_identifier'];
    $plugin_definition = [
    'label' => $configuration['label'] ?? '',
    'label' => $configuration['label'],
    'description' => $configuration['description'] ?? '',
    'weight' => $configuration['weight'] ?? 0,
    ] + $plugin_definition;
    ......
    ......@@ -3,7 +3,6 @@
    namespace Drupal\Core\Field;
    use Drupal\Core\Plugin\PluginBase;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    /**
    * Default object used for field_type_categories plugins.
    ......@@ -15,14 +14,14 @@ class FieldTypeCategory extends PluginBase implements FieldTypeCategoryInterface
    /**
    * {@inheritdoc}
    */
    public function getLabel(): TranslatableMarkup {
    public function getLabel(): string|\Stringable {
    return $this->pluginDefinition['label'];
    }
    /**
    * {@inheritdoc}
    */
    public function getDescription(): TranslatableMarkup {
    public function getDescription(): string|\Stringable {
    return $this->pluginDefinition['description'];
    }
    ......
    ......@@ -2,8 +2,6 @@
    namespace Drupal\Core\Field;
    use Drupal\Core\StringTranslation\TranslatableMarkup;
    /**
    * Provides an object that returns the category info about the field type.
    */
    ......@@ -12,18 +10,18 @@ interface FieldTypeCategoryInterface {
    /**
    * Returns the field group label.
    *
    * @return \Drupal\Core\StringTranslation\TranslatableMarkup
    * @return string|\Stringable
    * The category label.
    */
    public function getLabel(): TranslatableMarkup;
    public function getLabel(): string|\Stringable;
    /**
    * Returns the field group description.
    *
    * @return \Drupal\Core\StringTranslation\TranslatableMarkup
    * @return string|\Stringable
    * The category description.
    */
    public function getDescription(): TranslatableMarkup;
    public function getDescription(): string|\Stringable;
    /**
    * Returns the field group weight.
    ......
    ......@@ -14,7 +14,6 @@
    * @FieldType(
    * id = "test_field",
    * label = @Translation("Test field"),
    * description = @Translation("Dummy field type used for tests."),
    * default_widget = "test_field_widget",
    * default_formatter = "field_test_default"
    * )
    ......
    ......@@ -356,4 +356,18 @@ public function testFieldUiDefinitionsAlter() {
    $this->assertSession()->pageTextContains('Boolean (overridden by alter)');
    }
    /**
    * Ensure field category fallback works for field types without a description.
    */
    public function testFieldCategoryFallbackWithoutDescription() {
    $user = $this->drupalCreateUser(['administer node fields']);
    $node_type = $this->drupalCreateContentType();
    $this->drupalLogin($user);
    $this->drupalGet('/admin/structure/types/manage/' . $node_type->id() . '/fields/add-field');
    $field_type = $this->assertSession()->elementExists('xpath', '//label[text()="Test field"]');
    $description_container = $field_type->getParent()->find('css', '.field-option__description');
    $this->assertNotNull($description_container);
    $this->assertEquals('', $description_container->getText());
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment