Problem/Motivation

After an update from D11.3.13 to D11.4.0, i have this error with drush :
Fatal error: Type of Drupal\file_entity\Plugin\Field\FieldFormatter\FileImageResponsiveFormatter::$currentUser must be Drupal\Core\Session\AccountInterface (as in class Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter) in \web\modules\contrib\file_entity\src\Plugin\Field\FieldFormatter\FileImageResponsiveFormatter.php on line 28

Steps to reproduce

Migrate to D11.4.0

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

n.dhuygelaere created an issue. See original summary.

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

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

gurkawal’s picture

Hi @n.dhuygelaere

I was able to reproduce this after updating from Drupal 11.3 to Drupal 11.4.0

The issue happens because FileImageResponsiveFormatter extends core’s ImageFormatter, but it redeclares inherited properties without the same types now used by core in Drupal 11.4.

I created an MR to fix the compatibility issue

After applying the change, the fatal error is resolved.

n.dhuygelaere’s picture

StatusFileSize
new1.01 KB

Hi thanks,

based on your merge request i have created the attached patch. It works for D11.4.0 and drupal/file_entity:2.4 but it makes a fatal error on D11.3.13

joseph.olstad’s picture

have you tried 8.x-2.5-rc2 ???

joseph.olstad’s picture

I just tagged 8.x-2.5

please test against 11.4

joseph.olstad’s picture

Status: Active » Needs review
radinex’s picture

StatusFileSize
new969 bytes

The current patch created for the dev branch do not apply cleanly to the stable 8.x-2.5 (2.5.0) release of file_entity due to line number and whitespace context differences.

Furthermore, when updating to Drupal Core 11.4.0, because the stable 2.5.0 code is missing the use statements for AccountInterface and EntityStorageInterface at the top of the file, applying the dev patch directly results in a PHP compilation error: Fatal error: Class "Drupal\file_entity\Plugin\Field\FieldFormatter\AccountInterface" not found

To fix this on Drupal 11.4.0 with the stable file_entity 2.5.0 release, I have created a patch that uses the fully qualified class names (\Drupal\Core\Session\AccountInterface and \Drupal\Core\Entity\EntityStorageInterface). This allows the patch to apply cleanly to the stable release and resolves the PHP fatal error immediately without requiring additional class imports.

I have attached the patch below: file_entity-3607726-typehint-2.5.0.patch.

vvs’s picture

Status: Needs review » Reviewed & tested by the community

#10 is good for 2.6 and 11.4.2

joseph.olstad’s picture

previously this change was causing test failures

jaydarnell’s picture

Changes from merge request #33 apply cleanly to file_entity 2.6 and appear to work with Drupal core 11.4.4.

joseph.olstad’s picture

Status: Reviewed & tested by the community » Needs work

Can't merge this, it breaks phpunit testing, many fails.

uqjhawk3’s picture

Also confirm MR#33 working against 11.4.4 & file_entity 2.6

joseph.olstad’s picture

sure is a lot of test failures for D11.4.x

joseph.olstad’s picture

Status: Needs work » Active

joseph.olstad’s picture

Version: 8.x-2.4 » 8.x-2.x-dev
Status: Active » Fixed

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.

joseph.olstad’s picture

Version: 8.x-2.x-dev » 8.x-2.7

FIXED!

I had to also adjust the automated test due to an admin page in core moving around.

Thanks!

https://www.drupal.org/project/file_entity/releases/8.x-2.7

Everyone above has been creditted with the fix.

websiteworkspace’s picture

Is the following fatal error during {site}/update.php the same error that the patch above portends to repair?


PHP Fatal error:  

Type of Drupal\file_entity\Plugin\Field\FieldFormatter\FileImageResponsiveFormatter::
     $currentUser must not be defined (as in class Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter) in:

{site}/modules/file_entity/src/Plugin/Field/FieldFormatter/FileImageResponsiveFormatter.php on line 27

Had to set the composer.json file to version 2.6.0 to prevent module upgrade until these problems get repaired.

uqjhawk3’s picture

The above error also occurred for me on a 11.3.16 site. So perhaps this works with 11.4.x but breaks 11.3.x?

joseph.olstad’s picture

Thanks for the feedback, working on it.

joseph.olstad’s picture

hmm, looking to see if there's a better solution.

  • joseph.olstad committed c1ad4ff0 on 8.x-2.x
    fix: #3607726 Fatal error: Type of Drupal\file_entity\Plugin\Field\...
joseph.olstad’s picture

Ok 2.8 should do the job.

Sorry for the inconvenience and I thank you for the quick reporting.

https://www.drupal.org/project/file_entity/releases/8.x-2.8

websiteworkspace’s picture

Wow! Thank you for quickly pushing out a hot fix release.
-
Both the composer.json updating and the {site}/update.php runs were clean and in the green.
-
I then checked node bundles that use file entities and all seem good that i had time to check.
-
This hot fix release should hopefully reduce the number of problems that currently block upgrades to 11.4.x drupal core.