Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On filefield_paths_entity_update()
, when saving a media_entity entity.
Comments
Comment #2
jonhattanThe error is on a base field (thumbnail) provided by media_entity.
Base fields doesn't have third party settings, we need to ignore them.
Comment #3
Deciphered CreditAttribution: Deciphered at Realityloop commentedHi @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.
Comment #4
jonhattanSteps to reproduce:
1. Install a site with media_entity and filefield_paths modules:
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:
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.
Comment #5
jonhattanNow tat I've verbalized it, I've realized that
$definition instanceof ThirdPartySettingsInterface
is a better test.Comment #7
Deciphered CreditAttribution: Deciphered commentedIssue confirmed, thanks for the steps, makes the job of maintaining modules much easier ;)
Patch confirmed and committed.
Comment #9
titouilleHi !
I found the same problem by adding an image field in an entity using baseFieldDefinition::create.
Same test :
must be added in the filefield_paths_field_widget_form_alter function or we are facing the same error.
Comment #10
jonhattan@titouille please create a new issue and add the steps to reproduce it
Comment #11
amy.h CreditAttribution: amy.h commentedThis issue still persists with me and I have the most up to date version
Comment #12
kala4ekUp, issue still reproduced for me too.
Comment #13
kala4ekGot it, need to use DEV release.
There are no releases after 2015.
Comment #14
dabblela CreditAttribution: dabblela commentedStill an issue for me with a base image field attached to an entity (in this case, menu item). Patch attached
Comment #15
mibstar CreditAttribution: mibstar commentedI 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.
Comment #16
stevieb CreditAttribution: stevieb commentedJust to confirm the patch in #14 works when used with the dev branch
Comment #17
jptreen CreditAttribution: jptreen commented+1 The patch at #14 works when applied to beta1, too. (Drupal 8.5.1)
Comment #18
JFeltkampSame 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)
Comment #19
dercheffeWouldn't it make sense to release this issue in a stable release?
Comment #20
krystianbuczak CreditAttribution: krystianbuczak commentedConfirmed - DEV release fixes this issue. Please, merge to stable branch.
Comment #21
Kgaut CreditAttribution: Kgaut commentedI can confirm that this patch fix the error on image's basefield on custom entity type.
Comment #22
wil2091 CreditAttribution: wil2091 as a volunteer commentedRe-rolling the patch.
Comment #23
Kgaut CreditAttribution: Kgaut commentedLast patch from #22 works well with 1.0.0-beta2
Comment #24
jonathanshawThis issue is closed and fixed in #5.
Yes there are other problems with base fields not addressed in #5, but these are being addressed in #2718783: Call to undefined method BaseFieldDefinition::getThirdPartySettings(). Comment on that issue and use patches from that issue, please don't upload patches or comment here.