Problem/Motivation

I have encountered an error while deleting content.
note: I have trash module installed.

The website encountered an unexpected error. Please try again later.

Error: Call to a member function id() on null in Drupal\linkchecker\LinkExtractorService->saveLink() (line 353 of modules/contrib/linkchecker/src/LinkExtractorService.php).
Drupal\linkchecker\LinkExtractorService->saveLinkMultiple(Array) (Line: 185)
linkchecker_entity_update(Object)
call_user_func_array(Object, Array) (Line: 409)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'linkchecker') (Line: 388)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_update', Object) (Line: 416)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 217)
Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 900)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 564)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 781)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 489)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 339)
Drupal\Core\Entity\EntityBase->save() (Line: 33)
Drupal__node__NodeStorageTrash67514f1b54866->delete(Array) (Line: 347)
Drupal\Core\Entity\EntityBase->delete() (Line: 71)
Drupal\Core\Entity\ContentEntityDeleteForm->submitForm(Array, Object)
call_user_func_array(Array, Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
Drupal\Core\Form\FormBuilder->processForm('node_news_delete_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 280)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 124)
Drupal\cloudflare\CloudFlareMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

abu-zakham created an issue. See original summary.

abu-zakham’s picture

Issue summary: View changes
abu-zakham’s picture

Version: 2.1.0-alpha1 » 2.1.x-dev

dhruv.mittal’s picture

Assigned: Unassigned » dhruv.mittal

working on it

dhruv.mittal’s picture

Assigned: dhruv.mittal » Unassigned
Status: Active » Needs review

I've fixed the pipeline please review

dhruv.mittal’s picture

Assigned: Unassigned » dhruv.mittal
dhruv.mittal’s picture

Assigned: dhruv.mittal » Unassigned

I have removed the suggested changes please review.

shivam_tiwari’s picture

Status: Needs review » Reviewed & tested by the community

I checked MR 86 related changes from my end, and it looks fine so moving it to RTBC.

vladimiraus made their first commit to this issue’s fork.

vladimiraus changed the visibility of the branch 3491838-error-while-deleting to hidden.

vladimiraus’s picture

Great work everyone.
I no longer have permissions to merge. 🤷‍♂️
Waiting for someone with permissions.

vladimiraus’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Thanks everyone. 🧁
Merged and released.

Status: Fixed » Closed (fixed)

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

codebymikey’s picture

Just a thought, the linkchecker entity already has the $parent_entity->getEntityTypeId() and $parent_entity->id() as the parent_entity_type_id and parent_entity_id properties, so would it be better if those properties were exposed in the entity interface and used instead (allowing the original code to still work as expected without a null pointer, or is the skip the better behaviour)?

It'd probably also be a bit more performant as the entity will no longer be loaded during saves.

terry_kolodiy’s picture

StatusFileSize
new17.12 KB

Patch from MR (useful in my case, since I should not update Linkchecker to the latest version because of some incompatibilities)