Breaks some pages after install

Created on 26 May 2022, over 2 years ago
Updated 11 May 2023, over 1 year ago

Problem/Motivation

Some pages that fetch nodes are broken after installing and configuring the targets:

AssertionError: Cannot load the "target" entity with NULL ID. in assert() (line 295 of /var/www/html/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php)
#0 /var/www/html/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php(295): assert(false, 'Cannot load the...')
#1 /var/www/html/docroot/modules/contrib/targets/src/HttpKernel/PathProcessorTarget.php(129): Drupal\Core\Entity\EntityStorageBase->load(NULL)
#2 /var/www/html/docroot/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php(108): Drupal\targets\HttpKernel\PathProcessorTarget->processOutbound('/homepage', Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\GeneratedUrl))
#3 /var/www/html/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php(388): Drupal\Core\PathProcessor\PathProcessorManager->processOutbound('/homepage', Array, Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\GeneratedUrl))
#4 /var/www/html/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php(297): Drupal\Core\Routing\UrlGenerator->processPath('/node/6', Array, Object(Drupal\Core\GeneratedUrl))
#5 /var/www/html/docroot/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php(105): Drupal\Core\Routing\UrlGenerator->generateFromRoute('entity.node.can...', Array, Array, true)
#6 /var/www/html/docroot/core/lib/Drupal/Core/Url.php(763): Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute('entity.node.can...', Array, Array, true)
#7 /var/www/html/docroot/core/lib/Drupal/Core/Utility/LinkGenerator.php(182): Drupal\Core\Url->toString(true)
#8 /var/www/html/docroot/core/lib/Drupal/Core/Render/Element/Link.php(95): Drupal\Core\Utility\LinkGenerator->generate(Object(Drupal\Core\Render\Markup), Object(Drupal\Core\Url))
#9 [internal function]: Drupal\Core\Render\Element\Link::preRenderLink(Array)
#10 /var/www/html/docroot/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array)
#11 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(772): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')

This was triggered when it tried to create the following path: node/6/delete

The variable $node_target_id (124 on PathProcessorTarget.php) doesn't get set and causes it to fail down the line.

Steps to reproduce

Create a new install with content and install and configure the targets and go to an existing node page.

Proposed resolution

Multiple solutions are possible i think:

  1. On install resave all nodes
  2. Actually check if the target value exists before assigning it to the variable

Current workaround was resaving all nodes in the content overview after commenting out the code that break it.

πŸ› Bug report
Status

Fixed

Version

1.1

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium nielsaers

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024