Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonhattan created an issue. See original summary.

jonhattan’s picture

Deciphered’s picture

Hi @jonhattan,

Can you give me some reproduction steps? I assume there's another module involved, or custom/development code?

I only ask, as out of the box it doesn't appear that there's a simple way to create a Media Entity and I don't currently have the time to dig into the issue. If you can give me a way to reproduce the issue I can then confirm the patch and get it committed.

Thanks in advance.

jonhattan’s picture

Steps to reproduce:

1. Install a site with media_entity and filefield_paths modules:

cd /tmp
drush qd issue-2662420 media_entity media_entity_image filefield_paths --account-pass=admin --browser --yes

2. Login (admin/admin) and create a media bundle at http://127.0.0.1:8888/admin/structure/media/add (label: Image; Type provider: image)

3. Add a field of type Image to the media bundle: http://127.0.0.1:8888/admin/structure/media/manage/image/fields/add-field. Use all defaults. No need to configure filefield_paths

4. Finally create a media entity http://127.0.0.1:8888/media/add/image and save. Result:

Fatal error: Call to undefined method Drupal\Core\Field\BaseFieldDefinition::getThirdPartySettings() in /tmp/issue-2662420/drupal/modules/filefield_paths/filefield_paths.module on line 347

As stated above, the media entity provides a base field named thumbnail, of type image. Base fields don't have third party settings.

I've hit this problem in custom code several times, and I guess this will be a recurring issue across contrib.

API details:

* All field providers implements https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!FieldDefini...

* Fields created in the UI are FieldConfig instances - https://api.drupal.org/api/drupal/core!modules!field!src!Entity!FieldCon...

* FieldConfig ancestors are FieldConfigBase and ConfigEntityBase. At some point they implement ThirdPartySettingsInterface

* OTOH Base fields (properties in D7, as nid,title,created,,) are defined in code and implement https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!BaseFieldDe.... ThirdPartySettingsInterface is not implemented.

Deciphered’s picture

Status: Needs review » Fixed

Issue confirmed, thanks for the steps, makes the job of maintaining modules much easier ;)

Patch confirmed and committed.

Status: Fixed » Closed (fixed)

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

titouille’s picture

Hi !

I found the same problem by adding an image field in an entity using baseFieldDefinition::create.

Same test :

if ($definition instanceof Drupal\Core\Config\Entity\ThirdPartySettingsInterface) {...}

must be added in the filefield_paths_field_widget_form_alter function or we are facing the same error.

jonhattan’s picture

@titouille please create a new issue and add the steps to reproduce it

amy.h’s picture

This issue still persists with me and I have the most up to date version

kala4ek’s picture

Up, issue still reproduced for me too.

kala4ek’s picture

Got it, need to use DEV release.
There are no releases after 2015.

dabblela’s picture

Still an issue for me with a base image field attached to an entity (in this case, menu item). Patch attached

mibstar’s picture

I had the same error as @jonhattan but in my case it was caused by the https://www.drupal.org/project/consumers/releases/8.x-1.0-beta1 module.

Updating to the dev branch did not solve it, however the patch by @manatwo on https://www.drupal.org/node/2662420#comment-12199452 fixed it for me.

stevieb’s picture

Just to confirm the patch in #14 works when used with the dev branch

jptreen’s picture

+1 The patch at #14 works when applied to beta1, too. (Drupal 8.5.1)

JFeltkamp’s picture

Same issue from filefield_paths_field_widget_form_alter() returned in filefield_paths_entity_update().
I fixed it with the same check from #14. Now works for me. (Core 8.5.5, filefield_paths 1.0.0-beta1)

dercheffe’s picture

Wouldn't it make sense to release this issue in a stable release?

krystianbuczak’s picture

Confirmed - DEV release fixes this issue. Please, merge to stable branch.

Kgaut’s picture

I can confirm that this patch fix the error on image's basefield on custom entity type.

wil2091’s picture

Re-rolling the patch.

Kgaut’s picture

Last patch from #22 works well with 1.0.0-beta2