URL alias field on edit content form is always empty, causing the alias that was working fine to be deleted on save

Created on 13 July 2025, 3 days ago

Problem/Motivation

Path aliases which have been set are not showing on edit forms, resulting in the path alias being deleted when content is saved.

The summary says "No alias" even though the content does have an alias, and that alias is fully functional, working completely as expected, except for not showing up on the forms for node edit or taxonomy term edit etc (the text form field is simply blank for the URL alias field with the description 'Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.')

Steps to reproduce

My goodness, why would you want to?

(Sorry, i sadly don't know how to cause this to happen. This site was built when Drupal 8 was in alpha and has been semi-continuously upgraded since then, if that is relevant. This problem would seem to coincide with the upgrade to 11.2 from 11.1; at any rate i went through this site removing potentially related custom code, contrib modules, etc., changed the admin theme to Claro, and ultimately removed practically everything including those inconceivably related— like deleting all paragraphs and uninstalling paragraphs module to the point where the site had almost no content, until uninstalling things started to break the uninstaller and portions of the site— but i could still make new basic pages and give them an alias and see that while the alias was definitely saved correctly, or at least successfully:

+------+-------------+--------------------------------------+----------+------------+-----------+--------+
| id   | revision_id | uuid                                 | langcode | path       | alias     | status |
+------+-------------+--------------------------------------+----------+------------+-----------+--------+
| 1326 |        1326 | 25e04021-53d2-45f8-ae03-e0fc62a14737 | en       | /node/2348 | /testing  |      1 |
+------+-------------+--------------------------------------+----------+------------+-----------+--------+

And as noted this alias works great, except it does not show on the edit form.

Debugging core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php i can see that $items[$delta]->alias is indeed null but even here the alias is right there in the path item's values and retreivable with $items[$delta]->getValue()['alias']

(Oh to make things weirder, $items[$delta]->pid returns "1326" no problem.)

Proposed resolution

Ensure the 'alias' property on PathItems is set if there is a valid alias.

Remaining tasks

Ideally, develop a theory that could explain this problem and so possibly a better fix than simply re-assigning the alias property if it gets lost somehow.

User interface changes

None.

Introduced terminology

None.

API changes

Probably none.

Data model changes

Almost definitely none.

Release notes snippet

If a fix in core is somehow needed maybe we can quietly not mention it.

🐛 Bug report
Status

Active

Version

11.2 🔥

Component

path.module

Created by

🇺🇸United States mlncn Minneapolis, MN, USA

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

Comments & Activities

Production build 0.71.5 2024