Problem/Motivation
Under certain circumstances, when using Smart Date Recur, an ajax error is encountered when editing/overriding an event series instance. This was originally reported in issue #3210447 but the reporting user resolved the issue, and the issue was closed (as expected) due to lack of information and subsequent resolution.
The error is as follows:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /admin/content/smart_date_recur/154/instance/reschedule/10/ajax?_wrapper_format=drupal_ajax&ajax_form=1
StatusText: error
ResponseText: The website encountered an unexpected error. Please try again later.Drupal\Core\Entity\EntityStorageException: Route "entity.smart_date_override.canonical" does not exist. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php)."
This is caused due to a missing `entity.smart_date_override.canonical` route. The 'canonical' link template is definined in the Smart Date Override entity definition, but no corresponding route is provided. The problem is encountered when, for instance, custom/contrib code is creating a url string for the Smart Date Override entity. As it happens, the Next module is doing this for entities in an entity_insert hook.
The Smart Date Override entity defines these link templates:
* "canonical" = "/admin/content/smart_date_recur/overrides/{smart_date_override}",
* "add-form" = "/admin/content/smart_date_recur/overrides/add",
* "edit-form" = "/admin/content/smart_date_recur/overrides/{smart_date_override}/edit",
* "delete-form" = "/admin/content/smart_date_recur/overrides/{smart_date_override}/delete",
* "collection" = "/admin/content/smart_date_recur/overrides",
The Smart Date Recur module defines this route for the Smart Date Override entities:
entity.smart_date_override.delete_form:
path: '/admin/content/smart_date_recur/overrides/{smart_date_override}/delete'
defaults:
# Calls the form.delete controller, defined in the smart_date_override entity.
_entity_form: smart_date_override.delete
_title: 'Revert to Default'
requirements:
_permission: 'reschedule smart date recur instances'
Steps to reproduce
- In a fresh Drupal install, enable smart_date, smart_date_recur, and next modules
- Create a new content type: Event
- Add a Smart date range field to the Event content type
- Configure the smart date range field to allow for recurring events
- Create a new Event node which repeats weekly for a few weeks (the number of weeks is not important)
- Save the Event node
- Edit the Event node, and click the 'manage instances' button to reveal the instance override modal.
- Click the 'Override' link for one of the instances.
- Change the start or end time for the instance and click the Save button.
- Notice the modal doesn't respond to the save attempt.
- Open Devtools and see that there is an Drupal.AjaxError error thrown in the console.
Proposed resolution
Remove all but the delete-form link template from the Smart Date Override entity definition.
Remaining tasks
Write a unit test.
User interface changes
None.
API changes
None.
Data model changes
None.