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
- Install and enable decoupled_router.
- Create a node and set an alias for it (e.g. /test).
- 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
Issue fork decoupled_router-3166364
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
Comment #2
guillerecalde commentedComment #3
jfcolomer commentedThanks for this Guille,
I applied your patch and it does the trick :)
Comment #4
natedouglas commentedThanks. #2 fixed the issue on my deployment as well.
Comment #5
andre.bonon#2 works for me..
Thanks
Comment #6
johnennew commentedConfirmed, patch in #2 fixes the issue - thanks!
Comment #7
rp7 commentedI can confirm this issue & patch in #2 fixes it. Thank you.
Comment #8
el1_1el commented+1 Thank you!
Comment #9
briangonzalezmia+1 Thank you as well!
Comment #10
rollins commentedI 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.
Comment #11
rollins commentedComment #12
e0ipsoIs 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.
Comment #13
jebschiefer commentedWe 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.
Comment #14
fadonascimento commentedFor the last module release we need to change the patch from #2 to #10
#10 works as well!
Thanks
Comment #15
guillerecalde commentedI 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).
Comment #19
decipheredMerged 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.