Pathauto tokens aren't available

Created on 2 May 2019, over 5 years ago
Updated 21 March 2023, over 1 year ago

Pathauto uses hooks to generate paths which are executed after post save. The solution is probably to move token replacement to hooks.

See: #2972505-15: Pathauto 1.2 is not generating an alias after upgrading from 1.1 β†’

Original Report

When creating new content not all values are available before an entity is saved. For example, using [node:url:relative] produces the following error:

Drupal\Core\Entity\EntityStorageException: The "node" entity cannot have a URI as it does not have an ID in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 847 of /var/www/html/maritimetas/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

The solution is to move the token replacement to postSave().

πŸ› Bug report
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

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.

  • πŸ‡ΊπŸ‡ΈUnited States BradK

    The previous patch does not work for the new 3.x branch as the preSave() method in the FieldTokenValueItem class has been removed. The field_token_value_3.x_add_postSave_3052086.patch restores it and changes the method to postSave().

Production build 0.71.5 2024