Attempt to assign property "hash" on null

Created on 15 May 2023, over 1 year ago
Updated 14 July 2024, 3 months ago

Hello,

We are using cron to run drush command to start some imports every night. One of our feeds stopped working a few weeks ago and I didn't noticed back then so I don't really know what has changed and might be the reason why it stopped working.
Now I have unlocked the feed and if I try to import it manually I have this error:

Error : Attempt to assign property "hash" on null dans Drupal\feeds\Feeds\Target\EntityReference->setTarget() (/home/lamaison1080hethuis/public_html/web/modules/contrib/feeds/src/Feeds/Target/EntityReference.php ligne 126)

#0 /home/lamaison1080hethuis/public_html/web/modules/contrib/feeds/src/Feeds/Processor/EntityProcessorBase.php(1278): Drupal\feeds\Feeds\Target\EntityReference->setTarget()
#1 /home/lamaison1080hethuis/public_html/web/modules/contrib/feeds/src/Feeds/Processor/EntityProcessorBase.php(254): Drupal\feeds\Feeds\Processor\EntityProcessorBase->map()
#2 /home/lamaison1080hethuis/public_html/web/modules/contrib/feeds/src/EventSubscriber/LazySubscriber.php(110): Drupal\feeds\Feeds\Processor\EntityProcessorBase->process()
#3 [internal function]: Drupal\feeds\EventSubscriber\LazySubscriber->Drupal\feeds\EventSubscriber\{closure}()
#4 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func()
#5 /home/lamaison1080hethuis/public_html/web/modules/contrib/feeds/src/Event/EventDispatcherTrait.php(38): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#6 /home/lamaison1080hethuis/public_html/web/modules/contrib/feeds/src/FeedsExecutable.php(266): Drupal\feeds\FeedsExecutable->dispatchEvent()
#7 /home/lamaison1080hethuis/public_html/web/modules/contrib/feeds/src/FeedsExecutable.php(113): Drupal\feeds\FeedsExecutable->doProcess()
#8 /home/lamaison1080hethuis/public_html/web/core/includes/batch.inc(295): Drupal\feeds\FeedsExecutable->processItem()
#9 /home/lamaison1080hethuis/public_html/web/core/includes/batch.inc(137): _batch_process()
#10 /home/lamaison1080hethuis/public_html/web/core/includes/batch.inc(93): _batch_do()
#11 /home/lamaison1080hethuis/public_html/web/core/modules/system/src/Controller/BatchController.php(55): _batch_page()
#12 [internal function]: Drupal\system\Controller\BatchController->batchPage()
#13 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#14 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#15 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext()
#16 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#17 /home/lamaison1080hethuis/public_html/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#18 /home/lamaison1080hethuis/public_html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#19 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
#20 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#21 /home/lamaison1080hethuis/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#22 /home/lamaison1080hethuis/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#23 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#24 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#25 /home/lamaison1080hethuis/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#26 /home/lamaison1080hethuis/public_html/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle()
#27 /home/lamaison1080hethuis/public_html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#28 {main}

I have tried to understand if my configs/mappings might be responsible for this NULL problem but everything looks fine to me and I don't really understand why getItemByFeed is returning NULL and if it is important anyway because when I comment that line, the feed imports content whithout problem.

This issue looks related to my issue: https://www.drupal.org/project/feeds/issues/3252730 🐛 Feed items are constantly updated due to missing entity reference Active

But anyway, why was the feed working before a few weeks ago? What is hash and why should it be reset? Is it a problem if I get rid of this line? I have a lot of entity references that are not found and this is fine by me if they are kept not found.

Could anyone tell me if it is OK to just skip the hash reset?

Thank you!

💬 Support request
Status

Active

Component

Code

Created by

🇧🇪Belgium davidiio

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @davidiio
  • 🇳🇱Netherlands megachriz

    Is the feeds_item field missing? And an explanation about what the hash is

    Based on the error message it could be that on the entity to be imported the field "feeds_item" is missing. This field is used to track metadata about an import: which feed the content is imported with, when the last import happened and a hash of the item that was imported last. The hash is used to determine if a source item has changed since the last import.

    If a missing feeds_item is indeed the cause (not too sure about that, because I would have expected a different error message in that case), then that can be fixed by resaving the feed type. The feeds_item field will then be recreated.

    Are you using multiple feeds to update the same content?

    If a missing feeds_item is not the cause, then I'm wondering if you are using multiple feeds to update the same content? Because I did notice recently that something with the feeds_item field's data happened that didn't look right when I used two feeds to update the same content: a reference to one feed was kept, but a reference to the other feed was missing. But I haven't investigated yet if that bug is caused by Feeds or a custom module on the site.

    Why the hash should be reset

    A hash on the feed item is reset to NULL when a referenced entity cannot be found. If Feeds wouldn't reset it, the item won't be updated on a subsequent import, even if the referenced entity is available then.
    🐛 Feed items are constantly updated due to missing entity reference Active is indeed about accepting that some references don't exist and stop updating these entities every import.

  • 🇵🇹Portugal jrochate

    I was having this same problem.

    Even forcing to update records on every run, this error always poped-up.

    I found out that when a referenced entity did not exists, instead of feeds reporting that (as usual) it would break.

    I solved it by guarantying that the referenced entity always exists before running the feed that was rising the error.

    Maybe this can be helpful to anyone who comes here with the same problem: be sure that referenced entities (nodes) already exists.

Production build 0.71.5 2024