Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I am getting the following error when trying to synchronise remote entities:
[error] Error: Call to a member function getPublicName() on null in Drupal\entity_share_client\Service\JsonapiHelper->handlePhysicalFiles() (line 342 of /home/www-data/dev.nat/web/modules/contrib/entity_share/modules/entity_share_client/src/Service/JsonapiHelper.php) #0 /home/www-data/dev.nat/web/modules/contrib/entity_share/modules/entity_share_client/src/Service/JsonapiHelper.php(499): Drupal\entity_share_client\Service\JsonapiHelper->handlePhysicalFiles(Object(Drupal\file_entity\Entity\FileEntity), Array)
The error occurs here:
/**
* {@inheritdoc}
*/
public function handlePhysicalFiles(ContentEntityInterface $entity, array &$data) {
if ($entity instanceof FileInterface) {
$resource_type = $this->resourceTypeRepository->get(
'file', // entity_type_id
'file' // bundle
);
$uri_public_name = $resource_type->getPublicName('uri');
The error is caused by the hardcoded values for entity_type_id and bundle. In my case the entity type is `file` and bundle `image`. As there was no entity of type `file` and bundle `file`, the $resource_type was NULL and an error would occur.
This patch removes the hardcoded values for entity_type_id & bundle and obtains them from the entity instead.
Comment | File | Size | Author |
---|---|---|---|
#2 | properly_identify_file_entities-3088307-2.patch | 730 bytes | msti |
Comments
Comment #2
mstiComment #3
mstiComment #4
GrimreaperHi @msti,
Thanks for the bug report and the patch.
Are you using the file_entity module on your websites?
Comment #5
mstiHi Grimreaper
Yes we are kind of stuck with the the file_entity module
Comment #6
GrimreaperThanks @msti for the reply.
Yes, as you said "stuck", the file_entity module is deprecated so if there won't be any support in the entity share module dedicated to that.
But as it is a small change still compatible with standard file entity in Core, no problem. I am currently testing with the tests in the patch from #3072238-4: Tests: file field (entity reference).
If it is ok I will merge your patch.
Comment #8
GrimreaperTests green!
Patch merged!
Thanks for your contribution!