Problem/Motivation

After the installation of this module we experienced fatal errors on our site when updating or deleting nodes. In our logs we found this error:

Drupal\Core\Entity\EntityStorageException: The internal path component 'Array' is invalid. Its path component must have a leading slash, e.g. internal:/foo. en Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete() (linea 794 de /code/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

This error happens when you change the path alias to an existing node. We were able to reproduce this error in a Simplytest with a Drupal 8.9.3.

Steps to reproduce

  1. Install and enable decoupled_router.
  2. Create a node and set an alias for it (e.g. /test).
  3. Edit the recently created node, change the alias to something different (e.g. /test-2) and save it.

After the last step, the site shows "The website encountered an unexpected error. Please try again later.". The same thing occurs when trying to delete the node instead of updating it.

This is related to \Drupal\Core\Path\AliasManager class is deprecated

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

guillerecalde created an issue. See original summary.

guillerecalde’s picture

jfcolomer’s picture

Thanks for this Guille,
I applied your patch and it does the trick :)

natedouglas’s picture

Thanks. #2 fixed the issue on my deployment as well.

andre.bonon’s picture

#2 works for me..
Thanks

johnennew’s picture

Status: Active » Reviewed & tested by the community

Confirmed, patch in #2 fixes the issue - thanks!

rp7’s picture

I can confirm this issue & patch in #2 fixes it. Thank you.

el1_1el’s picture

+1 Thank you!

briangonzalezmia’s picture

+1 Thank you as well!

rollins’s picture

I applied a patch #2, and got warnings after node save:
Warning: Illegal string offset 'source' in Drupal\decoupled_router\CacheInvalidator->invalidateByPath() (line 54 of modules/contrib/decoupled_router/src/CacheInvalidator.php).
Drupal\decoupled_router\CacheInvalidator->invalidateByPath('/node/190') (Line: 17)
decoupled_router_path_alias_update(Object)
call_user_func_array('decoupled_router_path_alias_update', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('path_alias_update', Array) (Line: 204)
Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 843)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 17)
Drupal\path_alias\PathAliasStorage->invokeHook('update', Object) (Line: 535)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 728)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 460)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 837)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 395)
Drupal\Core\Entity\EntityBase->save() (Line: 105)
Drupal\Core\Path\AliasStorage->save('/node/190', '/imprint3', 'de', '296259') (Line: 262)
winners_api_entity_update(Object)
call_user_func_array('winners_api_entity_update', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_update', Array) (Line: 206)
Drupal\Core\Entity\EntityStorageBase->invokeHook('update', Object) (Line: 843)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 535)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 728)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 460)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 837)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 395)
Drupal\Core\Entity\EntityBase->save() (Line: 294)
Drupal\node\NodeForm->save(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: 592)
Drupal\Core\Form\FormBuilder->processForm('node_simple_page_edit_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
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: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Here patch to fix this warnings, I updated the same functions as #2.
Just made same structure for update and delete functions as it was for insert function.

rollins’s picture

Status: Reviewed & tested by the community » Needs review
e0ipso’s picture

Is anyone here able to confirm that this is not an issue for version 2.x of the module? The recommended fix then would be to upgrade.

jebschiefer’s picture

We had been using this patch with 1.x and then with 2.x. Removed the patch and reinstalled 2.x and it seems to be working.

fadonascimento’s picture

For the last module release we need to change the patch from #2 to #10

#10 works as well!
Thanks

guillerecalde’s picture

I can confirm that this issue has been resolved in the version 2.x of the module. While the patch #10 is useful for removing deprecated code, it is not strictly necessary to apply it to make the module work (we will need to apply #10 for Drupal 9 though https://www.drupal.org/node/3013865).

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

  • deciphered committed cafc030c on 2.x
    fix(#3166364): replace dead path hooks with entity hooks
    
deciphered’s picture

Status: Needs review » Fixed

Merged as !40. Thanks to everyone who tested and confirmed the original patches over the years, especially guillerecalde for the initial report and patch, and rollins for the patch it's built on.

The fix replaces the dead hook_path_update()/hook_path_delete() implementations with hook_path_alias_update()/hook_path_alias_delete(), and switches from getAlias() to getPath() across all three hooks so cache tags resolve against the correct entity. It also invalidates the original source path when an alias is repointed, so the entity that lost the alias doesn't keep serving a stale cached response.

Will ship in the next release (2.0.7). Closing as fixed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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