Closed (fixed)
Project:
Tombstones
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Aug 2021 at 18:15 UTC
Updated:
1 Sep 2025 at 08:39 UTC
Jump to comment: Most recent
Drupal 9 has removed the service 'path.alias_storage' and have been reverted to revisionable entities, see link to drupal 9 documentation.
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!
| Comment | File | Size | Author |
|---|---|---|---|
| drupal9-tombstone.patch | 752 bytes | tocao19 |
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
avpadernoComment #3
avpadernoGiven that Drupal releases before 8.9.x aren't anymore supported, and the path.alias_storage service has been removed from Drupal 8.8.0, sites using this module are now facing this error.
Only one of those lines is required to save the path alias entity, preferably the first one.
Comment #6
abrammMade the MR with a fix.
Follow-up issues:
- #3535769: Tombstones URLs are only created for English paths
- #3535761: Use dependency injection
Comment #7
abrammComment #9
abramm