Redirecting a request during delete an entity when the redirect are disabled

Created on 19 October 2023, over 1 year ago

Problem/Motivation

Using AJAX Comments module to control all comments in an entity, and these comments are being related to another entity as a notification system.
The notification behavior will add a batch to keep the notification updated following the main entity or to be deleted when the main entity is deleted.

The FormBuilder class has two important validations for delete an entity for this scenario. One of them is to check if the current request is Ajax to avoid redirects, and another validation to determine when a batch process was started and then redirect to the batch page.
The batch validation is ignoring the Ajax validation and redirecting to the batch page. However, it needs to ignore the redirect because the request is Ajax.

Reference validation:

  • html/core/lib/Drupal/Core/Form/FormBuilder.php:603

Steps to reproduce

  1. Install and enable the Ajax Comments
  2. Create a hook_entity_delete to start a simple batch when a comment is being deleted
  3. Create a content from any entity and enable comments for them
  4. Clear cache
  5. Add some comments to the created content
  6. Try to delete a comment and look the error at browser console

Proposed resolution

The FormBuilder class already have a function imported to them to check if that request can be redirect looking the form-state, so, add this function at batch validation.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

🐛 Bug report
Status

Active

Version

9.5

Component
Entity 

Last updated 1 day ago

Created by

🇧🇷Brazil viniciusrp

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024