fix(Page): #3591763 Publishing a page without a URL alias fails: its empty...
Publishing a canvas_page without a URL alias fails with a 500 when Pathauto is
installed. ContentEntityStorageBase::invokeHook('presave') runs field
preSave() before presave hooks are invoked, and FieldItemList::preSave()
filters empty items. A path item without an alias is empty and gets removed, so
PageHooks::ensurePathautoSkipped() receives NULL from first() and the
assertion fails. Pages with an existing alias are unaffected.
This MR appends a new path item when the list is empty, then sets
PathautoState::SKIP on it as before. It adds a PagePathautoIntegrationTest
kernel test that covers saving pages with and without an alias.
AI-Generated: Yes (Used Claude Code to diagnose the root cause and write the fix and test; reviewed and manually tested by me).
Testing instructions
- Install Canvas and Pathauto on Drupal 11.4.
- Create a new page in the Canvas UI. Do not set a URL alias.
- Publish the page. Without this MR the publish request returns a 500
(
AssertionError: assert($pathauto_item instanceof PathautoItem)). With this MR it succeeds. - Confirm the page still gets no auto-generated URL alias.
Closes #3591763