Download & Extend

Split drupal_goto into smaller, modular functions

Project:Drupal core
Version:7.x-dev
Component:base system
Category:task
Priority:normal
Assigned:Unassigned
Status:postponed

Issue Summary

This patch splits drupal_goto into three functions:
drupal_goto - which behaves exactly the same way it does now.
drupal_get_goto_url - which is responsible for constructing the redirect URL.
drupal_goto_finalize - which calls hook_exit and closes the session.

The use case for this is an ajax module that wants to replace a call to drupal_goto with a function that sends the redirect path to the javascript to let the clientside logic decide what to do next.

Along with #376142: add hook_form_process_success to drupal_form_process, this patch has been extracted from #193311: Ajax Popups in Drupal 7: Adding Modal Dialogs to Help, Confirmations and Filter tips (Unified), with the goal of creating a more powerful version of #374646: Popbox (Popups Lite): Adding Modal Dialogs to Confirmations.

AttachmentSizeStatusTest resultOperations
drupal_goto.patch2.42 KBIdlePassed: 10268 passes, 0 fails, 0 exceptionsView details | Re-test

Comments

#1

I don't have any direct suggestions but I find the proposed API not very intuitive. The function names are not particularly explanatory and feel 'too low level' to be a good API.

#2

I agree with Dries, I don't see this being very useful in core or the API being descriptive at all.

#3

This is one small piece for making Drupal more friendly to ajax forms. When you do an ajax form submission, a lot of the time you do not want to trigger a redirect. Instead, you want to find out the result of the submission, and make your own choices about how to display that information. And sometimes, the choice is you make is, ok do the redirect. To do all that, you need to know where the directed was going to go.

Right now, it seems like drupal_goto does three things
1) Calculate where the redirect will go, using it's parameters and the destination param.
2) Finish up any loose ends by calling hook_exit and closing the session.
3) Actually calling the redirect.

If #376142: add hook_form_process_success to drupal_form_process was in place, in my hook_form_process_success I might want to call the first function to get the url, write out that url (and some other status info) as json, call the second function, and exit.

I would love suggestions if there is a better way to accomplish this, or, if it is just a question of naming, what better function names might be.

#4

Status:needs review» postponed

After talking with merlinofchaos, I think this can be better handled by creating a new form_goto($form, $form_state) function and calling that in drupal_form_redirect.
Now I just need #322344: (notice) Form improvements from Views to be committed.

nobody click here