After upgrading to Drupal 10.2, my website won't work anymore because getDescription signature of ConfigEntityDescriptionTrait is not compatible with EntityDisplayModeBase class

Edit: Erratum, the issue is only on 10.2. Composer installed 10.2-alpha instead of 10..1.7 for no good reason.

Command icon Show commands

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

arnaud-brugnon created an issue. See original summary.

arnaud-brugnon’s picture

Status: Active » Needs review
StatusFileSize
new434 bytes

Here's a fix

Status: Needs review » Needs work

The last submitted patch, 2: 3408813-2.patch, failed testing. View results

arnaud-brugnon’s picture

Issue summary: View changes

viren18febS made their first commit to this issue’s fork.

viren18febs’s picture

Status: Needs work » Needs review
StatusFileSize
new610 bytes

I have resolved the issue & added patch, please review.

ckhalilo’s picture

Must add string as Type of function getDescription()

public function getDescription() :string {
You can simply add (string) in return

return (string) $this->getThirdPartySetting('lightning_core', 'description');

Environment
- PHP8.2
- D10.2

goldfit’s picture

StatusFileSize
new757 bytes

I have resolved the issue with the provided changes.

goldfit’s picture

StatusFileSize
new551 bytes

Patch without the header informations :)

siddharthjain’s picture

The patch shared in #9 applies smoothly. Thanks for the patch @Goldfit

tommasorandazzo’s picture

+1 to patch in #9.

tommasorandazzo’s picture

Status: Needs review » Reviewed & tested by the community
tommasorandazzo’s picture

alina.basarabeanu’s picture

We came across the same error after upgrading to Drupal core 10.2.
The patch provided by #9 fixed the issue.
Please add this to a new stable release.

ananthakrishnan.kr’s picture

After upgrading to Drupal core 10.2 we also came across the same error.
Patch #9 fixed the issue.

manikandank03’s picture

I am also facing the same issue after upgrade Drupal 10.2.2 with PHP 8.2 and tried this patch #9, the issue fixed now and site was working fine.

samlerner’s picture

The patch in #9 worked for me as well, upgrading to 10.2 with PHP 8.1. Thanks!

Rajeshreeputra made their first commit to this issue’s fork.

rajeshreeputra’s picture

Created MR for quick merge.

drupalam’s picture

I ran into this issue with the `lightning_core` module following an upgrade of Drupal from version 10.1.8 to 10.3.1. Unfortunately, patch number 9 was ineffective for me because I needed to fix both functions in the `ConfigEntityDescriptionTrait.php` file. The patch provided below resolved the problem and I will create a Merge Request to make it permanent.

baluertl’s picture

Issue summary: View changes
baluertl’s picture

It is now tested, +1 for RTBC. Even $ drush en lightning_core results in an exception which makes the entire site unusable.

  • lightning_core: 6.0.x-dev
  • Core: 10.3.1
  • PHP: 8.3.9

Unfortunately, the main repo still believes 8.x-5.x as the default branch. However, a newer version of this module has already been released from another branch with a higher version number (6.x). This confusion caused both merge requests here still target the “legacy” 8.x-5.x branch. Only users opening the MR are allowed to re-target to the correct development HEAD – I did not find an option on GitLab GUI to do so.

Also, marking as a blocker of #3369498: Automated Drupal 11 compatibility fixes for lightning_core + enable GitLab CI.

baluertl’s picture

Version: 8.x-5.14 » 6.0.x-dev
puregin’s picture

@drupalam, sorry to be weighing in on this late in the game, but we have in core/lib/Drupal/Core/Entity/EntityDescriptionInterface.php the following:

 /**
     * Sets the entity description.
     *
     * @param string $description
     *   The entity description.
     *
     * @return $this
     */
    public function setDescription($description);

It seems that setDescription() returns $this (an EntityDescriptionInterface), so trying to coerce the result to a string as in #21 is going to give a type error, unless I'm missing something.

mariaannuar’s picture

StatusFileSize
new880 bytes

@puregin was correct! Here’s a solution to this

rafal.sereda’s picture

Hi - just a double confirmation note from my side, that the 2 comments above are correct. #20 worked for me, #27 should work too, the #21 results with an error when saving new View Mode.

kreynen’s picture

Late to this party, but I just ran into this upgrading a D9 site. #27 worked for me on 10.5.1. Always grateful when fixes are so easy to find. THANKS!

balsama made their first commit to this issue’s fork.

balsama’s picture

Status: Reviewed & tested by the community » Fixed

b6f1efec608edb87c3838e55855678b6cad873c3

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

balsama changed the visibility of the branch 3408813-fix-for-10-3-1 to hidden.

balsama changed the visibility of the branch 3408813-fatal-error-declaration to hidden.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.