Error with module EntityBrowser

Created on 22 May 2019, over 5 years ago
Updated 12 December 2023, 11 months ago

Hello,

We're having an issue when using this module with Contrib Module Entity Browser.

Error: Call to undefined method stdClass::getValue() in animated_gif_preprocess_image_formatter() (line 11 of /app/docroot/modules/contrib/animated_gif/animated_gif.module)

This fatal error is ocurring when we try to access File Listing.

Image

Basically the object is getting $image = $variables['item']; does not have the getValue() method and it's throwing a fatal error.

It would see that when chosing a file that has already been loaded, it's passing through this module and causing an error.

I was able to solve the issue by adding a validation, if the object doesn't have getValue() method, don't run the code.

Is there a better approach to solve this issue?

🐛 Bug report
Status

Postponed: needs info

Version

2.0

Component

Code

Created by

🇪🇸Spain uridrupal

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I'm encountering a similar error but in a different scenario:

    Error: Call to a member function getValue() on array in animated_gif_preprocess_image_formatter()

    Anyway I think the solution for the error in the issue description would also solve that error I found. As for the patch in #14, I think that this won't be sufficient and is lacking a basic validation of whatever is inside $variables['item'] is actually an object or even is set at all. So maybe something like

    if (empty($variables['item']) || $variables['item'] instanceof \Drupal\image\Plugin\Field\FieldType\ImageItem) {
      return;
    }
    

    would solve the error described in the IS as well as the one I'm encountering.

    In my case, the steps to replicate this are the following (it includes other contribs, so not sure if it's a great example):

    On Vanilla Drupal 9.5.x

    1. $ drush si -y && drush en -y admin_toolbar_tools, media, component_library, media_library && drush uli
    2. Add a media reference field to the article content type and make sure it's using the Media Library widget on the node form
    3. Create an article node adding an image media in the media field
    4. Enable the animated_gif module
    5. Refer to the following screencast for further steps

  • Status changed to Needs work over 1 year ago
  • Status changed to Needs review over 1 year ago
  • 🇪🇸Spain jansete

    Reroll patch for the last version.

  • 🇫🇷France Grimreaper France 🇫🇷
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Composer require failure
  • Status changed to Postponed: needs info over 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    I tried to reproduce from the steps provided in comment 17.

    No problem. I tried with image field, image field with entity browser, media field.

    In this gif screencast you will see my entity browser view configuration.

  • 🇪🇸Spain jansete

    I remember that for me I could reproduce with fields that have multiple fields, maybe entity reference with multiple images in the field, because in xdebug y showed an entitties array instead a single entity, for me the last patch worked

  • 🇳🇱Netherlands Ruuds

    See the attached patch for a version which works with the 2.x branch.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update 11 months ago
    2 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MySQL 5.7
    last update 11 months ago
    2 pass
Production build 0.71.5 2024