Error: Call to a member function hasCanonical() on null in Drupal\storage\Entity\Storage->hasLinkTemplate()

Created on 31 May 2025, 3 days ago

Problem/Motivation

I applied a recipe that installs Storage, but it threw a fatal error:

[error]  Error: Call to a member function hasCanonical() on null in Drupal\storage\Entity\Storage->hasLinkTemplate() (line 212 of /var/www/html/web/modules/contrib/storage/src/Entity/Storage.php) #0 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(538): Drupal\storage\Entity\Storage->hasLinkTemplate()
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(407): Drupal\Core\Entity\EntityBase->invalidateTagsOnSave()
#2 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(492): Drupal\Core\Entity\EntityBase->postSave()
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(563): Drupal\Core\Entity\ContentEntityBase->postSave()
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(781): Drupal\Core\Entity\EntityStorageBase->doPostSave()
#5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(489): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave()
#6 /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(805): Drupal\Core\Entity\EntityStorageBase->save()
#7 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
#8 /var/www/html/web/modules/contrib/event_platform/event_platform_details/event_platform_details.install(36): Drupal\Core\Entity\EntityBase->save()
#9 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(744): event_platform_details_install()
#10 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(368): Drupal\Core\Extension\ModuleInstaller->invoke()
#11 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install()
#12 /var/www/html/web/core/lib/Drupal/Core/Recipe/RecipeRunner.php(274): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install()
#13 [internal function]: Drupal\Core\Recipe\RecipeRunner::installModule()
#14 /var/www/html/web/core/lib/Drupal/Core/Recipe/RecipeCommand.php(97): call_user_func_array()
#15 /var/www/html/vendor/symfony/console/Command/Command.php(279): Drupal\Core\Recipe\RecipeCommand->execute()
#16 /var/www/html/vendor/symfony/console/Application.php(1094): Symfony\Component\Console\Command\Command->run()
#17 /var/www/html/vendor/symfony/console/Application.php(342): Symfony\Component\Console\Application->doRunCommand()
#18 /var/www/html/vendor/symfony/console/Application.php(193): Symfony\Component\Console\Application->doRun()
#19 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#20 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#21 /var/www/html/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
#22 /var/www/html/vendor/bin/drush.php(119): include('...')
#23 {main}.
Error: Call to a member function hasCanonical() on null in /var/www/html/web/modules/contrib/storage/src/Entity/Storage.php on line 212 #0 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(538): Drupal\storage\Entity\Storage->hasLinkTemplate()
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(407): Drupal\Core\Entity\EntityBase->invalidateTagsOnSave()
#2 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php(492): Drupal\Core\Entity\EntityBase->postSave()
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(563): Drupal\Core\Entity\ContentEntityBase->postSave()
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(781): Drupal\Core\Entity\EntityStorageBase->doPostSave()
#5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(489): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave()
#6 /var/www/html/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(805): Drupal\Core\Entity\EntityStorageBase->save()
#7 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(354): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()
#8 /var/www/html/web/modules/contrib/event_platform/event_platform_details/event_platform_details.install(36): Drupal\Core\Entity\EntityBase->save()
#9 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(744): event_platform_details_install()
#10 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(368): Drupal\Core\Extension\ModuleInstaller->invoke()
#11 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83): Drupal\Core\Extension\ModuleInstaller->install()
#12 /var/www/html/web/core/lib/Drupal/Core/Recipe/RecipeRunner.php(274): Drupal\Core\ProxyClass\Extension\ModuleInstaller->install()
#13 [internal function]: Drupal\Core\Recipe\RecipeRunner::installModule()
#14 /var/www/html/web/core/lib/Drupal/Core/Recipe/RecipeCommand.php(97): call_user_func_array()
#15 /var/www/html/vendor/symfony/console/Command/Command.php(279): Drupal\Core\Recipe\RecipeCommand->execute()
#16 /var/www/html/vendor/symfony/console/Application.php(1094): Symfony\Component\Console\Command\Command->run()
#17 /var/www/html/vendor/symfony/console/Application.php(342): Symfony\Component\Console\Application->doRunCommand()
#18 /var/www/html/vendor/symfony/console/Application.php(193): Symfony\Component\Console\Application->doRun()
#19 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#20 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#21 /var/www/html/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run()
#22 /var/www/html/vendor/bin/drush.php(119): include('...')
#23 {main}
Error: Call to a member function hasCanonical() on null in Drupal\storage\Entity\Storage->hasLinkTemplate() (line 212 of /var/www/html/web/modules/contrib/storage/src/Entity/Storage.php).

Proposed resolution

Within the hasCanonical method, check that $type is not null before trying to call for the link template.

🐛 Bug report
Status

Active

Version

1.4

Component

Code

Created by

🇨🇦Canada mandclu

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024