API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21fo...
Enter a descriptive title (above) relating to function callback_batch_finished, then describe the problem you have found:
While batch_process does indicate that a RedirectResponse can be returned, callback_batch_finished does not but the code for it indicates that it is possible to redirect a RedirectResponse (and it works as such).
// Determine the target path to redirect to. If a batch 'finished' callback
// returned a redirect response object, use that. Otherwise, fall back on
// the form redirection.
if (isset($batch_finished_redirect)) {
return $batch_finished_redirect;
}I would suggest we update it to match batch process by adding the following:
Return value
\Symfony\Component\HttpFoundation\RedirectResponse|null A redirect response if the batch is progressive. No return value otherwise.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 2860627-nr-bot.txt | 681 bytes | needs-review-queue-bot |
| #21 | 2860627-nr-bot.txt | 1.21 KB | needs-review-queue-bot |
Issue fork drupal-2860627
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
markdorisonComment #11
quietone commentedLooking at the code for callback_batch_finished, it returns a void. I don't see anything to fix here. Re-open if I am wrong.
Thanks
Comment #12
scott_euser commentedLooking back at this issue, I think my point was that
form.api.phpis code which serves as a sort of documentation for what https://git.drupalcode.org/project/drupal/-/blob/9.5.x/core/includes/bat... allows you to do. It however does not indicate that you are allowed to return aRedirectResponse, yet that above function shows that you can actually return aRedirectResponseand it will redirect the user after the batch processing is finished.So there is a nice feature that is useful for developers, yet the documentation does not explain that that feature exists. You need to spot it yourself in the
_batch_finished()function.Comparatively, the
`batch_process()`function does explain this as a possibility.I would be happy to put this into a merge request.
Comment #13
joachim commented> redirect response if the batch is progressive. No return value otherwise.
I'm not sure what a *progressive* batch is.
The docs should say that a RedirectResponse *may* be returned, to send the user to a page other than the default batch results page.
They should also say that if there are multiple batch sets, only the last redirect is used:
It would be nice also if the sample code had a redirect added to it, e.g.:
Tagging as novice, updating version, and setting to bug report as this is missing documentation.
Comment #17
diederik.beirnaert commentedUpdated documentation for callback_batch_finished to include RedirectResponse.
And added an example:
Comment #18
joachim commentedNearly there -- looks good overall, just a few formatting fixes needed.
Comment #19
diederik.beirnaert commentedDid the codestyle fixes Joachim suggested.
Comment #20
diederik.beirnaert commentedComment #21
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #22
diederik.beirnaert commentedmoved comment that was placed after line of code.
Comment #23
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.