Problem/Motivation

I update my site and get the error:

Fatal error: Declaration of Drupal\tome_sync\Normalizer\EntityReferenceItemNormalizer::normalize($field_item, $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null must be compatible with Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer::normalize($field_item, $format = null, array $context = []): array in /var/www/html/web/modules/contrib/tome/modules/tome_sync/src/Normalizer/EntityReferenceItemNormalizer.php on line 17

Many of the administration screens only show that error.

Issue fork tome-3607811

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

koffer created an issue. See original summary.

koffer’s picture

I install local a new drupal with 11.4.0 and install Tome modules and at first the site work or at least I can navigate like a normal new drupal site, but when I try to create a new node I get the same error:

Fatal error: Declaration of Drupal\tome_sync\Normalizer\EntityReferenceItemNormalizer::normalize($field_item, $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null must be compatible with Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer::normalize($field_item, $format = null, array $context = []): array in /var/www/html/web/modules/contrib/tome/modules/tome_sync/src/Normalizer/EntityReferenceItemNormalizer.php on line 17

larowlan’s picture

Yep, breaking change in core unfortunately - we need to change the return typehint to :array

larowlan’s picture

koffer’s picture

I was able to fix the site doing some change in code.

I change the files in /tome_sync/src/Normalizer/

so I switch from:

public function normalize($field_item, $format = null, array $context = []): ArrayObject|array|string|int|float|bool|null

to something like:

public function normalize($field_item, $format = null, array $context = []): array

and basically change all files there to use []): array

It's a rather naive change, but at least the site started working and I was actually able to start exporting with Tome and updating the website online.

If I check with drush ws I still get the errors:

PHP Deprecated: Drupal\tome_sync\Normalizer\PathAliasNormalizer::__construct(): Implicitly marking parameter $entity_type_repository as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/tome/modules/tome_sync/src/Normalizer/PathAliasNormalizer.php on line 42

But At least I get site online again. I hope Tome modules get a better solution Soon.

koffer’s picture

Title: Error with Drupal 11.4.0 » Fatal error with Drupal 11.4.0
larowlan’s picture

Thanks koffer - are you interested in creating a merge-request with your fixes?

The PHP Deprecated issue is #3586893: Patch for PHP 8.4 (explicit nullable type)

I could do a new release with both fixes

koffer’s picture

Hi. I prefer that you continue with the solution in the other issue. My solution involved asking the AI, and I don't have much knowledge about how the Tome module works. I think it would complicate things if I added my code.

larowlan’s picture

Ok, thanks - I will try to resolve it this week

joseph.olstad’s picture

joseph.olstad’s picture

Status: Active » Needs review

combined the php 8.4 deprecation fix along with the typehint compatibility fix.

joseph.olstad’s picture

larowlan’s picture

Also looks like you've bundled some D12/dr compatibility?

I'm happy to do both in one, but it will take a bit longer, so I'm thinking fix the fatal on 11.4 and the 8.4 issue and come back for D12

  • larowlan committed 15f9a66d on 8.x-1.x
    fix: #3607811 Fatal error with Drupal 11.4.0
    
    By: koffer
    By: larowlan
    By...
larowlan’s picture

Status: Needs review » Fixed

https://www.drupal.org/project/tome/releases/8.x-1.15

I'll do the other stuff in D12 fixes - the module only has low installs (1200) but I'm nearly up to modules that low in usage so it should come around in the next fortnight

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.

mr.white’s picture

StatusFileSize
new1.47 KB

There are related errors that appear upon user login with Drupal 11.4.1 and Tome 1.15. This patch appears to fix them.

joseph.olstad’s picture

@mr.white that patch looks like a revert of the fix?

joseph.olstad’s picture

mr.white’s picture

I believe the fix was applied too broadly and this rolls back a specific instance.

  • larowlan committed 62caa8cd on 8.x-1.x
    fix: #3607811 Fatal error with Drupal 11.4.0
    
    By: koffer
    By: larowlan
    By...
larowlan’s picture

thanks @mr.white - you're correct that function does indeed return things that aren't an array - https://www.drupal.org/project/tome/releases/8.x-1.16 includes the change

joseph.olstad’s picture

k00l thx

mr.white’s picture

8.16 is working well for me.

Great work, everyone! 👏

larowlan’s picture

Looking for testers on #3609621: Resolve test failure and errors. which preps the module for D12