You have requested a non-existent service "path.alias_storage"

Created on 13 August 2021, about 4 years ago
Updated 14 July 2025, 3 months ago

Problem/Motivation

Drupal 9 has removed the service 'path.alias_storage' and have been reverted to revisionable entities, see link to drupal 9 documentation β†’ .

Steps to reproduce

  1. Enable the current tombstone module, configure it to delete any content type
  2. Create a dummy content type of the type set above and then proceed to delete it
  3. Webpage will white screen and the error in the log will be something along the line of "You have requested a non-existent service "path.alias_storage". in Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete() "

Proposed resolution

Following the instructions here β†’ , the following code/patch is proposed to allow for tombstones to work with Drupal 9

diff --git a/src/TombstonesService.php b/src/TombstonesService.php
index 5afcae4..f080092 100644
--- a/src/TombstonesService.php
+++ b/src/TombstonesService.php
@@ -58,7 +58,14 @@ class TombstonesService {
       'field_tombstone_path' => $tombstone_metadata['path'],
     ]);
     $tombstone->save();
-    \Drupal::service('path.alias_storage')->save("/node/" . $tombstone->id(), $tombstone_metadata['path'], "en");
+    
+    $path_alias = \Drupal::entityTypeManager()->getStorage('path_alias')->create([
+      'path' => "/node/" . $tombstone->id(),
+      'alias' => $tombstone_metadata['path'],
+      'langcode' => "en",
+    ]);
+    $path_alias->save();
+    \Drupal::entityTypeManager()->getStorage('path_alias')->save($path_alias);
   }
 
 }

Thanks!

πŸ› Bug report
Status

Needs work

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada tocao19

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

Merge Requests

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