Here is an interesting problem.
I realized that during the installation process there is something called the Batch API! I never heard of this this I discovered it in the code. see Batch API for more info. It is actually really simple and elegant (quite like everything in drupal).
Anyways, it turns out during the batch process all form submissions (i.e. using drupal_execute() ) get intercepted by the form handler and then passed in to the batch process (for later processing?). look at this code form_execute_hander() for the details. This leads to some problems that I don't think were thought of during designing of the Batch API.
The whole installation process of the enabling of modules is run through a Batch Process, that's why you get a progress bar and it doesn't time out. Thus, if any modules need to run a form during the installation of a module, i.e. in the hook_install() of the module, the forms won't be process when they are executed, they will be processed later, if at all. (I'm still trying to figure this out).
So my inquiry is if there is someway to pause a batch during the run, so the forms can be processed immediately and not intercepted to be appended to to the batch?
Comments
not just during installation
When ever a batch is running and a form needs to be processed, all submissions get intercepted and are never run. So for example you are creating a batch to insert 100 user through a particular form then form will never be submitted.
I had to hack the core to disable this functionality before I run the batch, which so far, i've never had to do. (make changes to the core)
still looking into alternatives.
I found a way around this issue
I found a way around this problem. without hacking core!!!!
If during the batch you need to execute a form that is not part of the batch sequence, i,e, one of the batch operators, you can effectively pause the batch or prevent the batch process from intercepting your form submissions with the following code...
put the code in the batch operator that executes the form
IMPORTANT: make sure that you won't time out during the execution of the form or you will probably defeat the whole purpose of the batch.
You can now use the batch API to do just about anything... this is really exciting...
now we just have to figure out a way around out of memory errors and the sky is the limit!
This is a bug in D6 and has been fixed
In the early versions of D6 this was an issue.
#297972: drupal_execute is incompatible with batch API
It has been fixed, which is essentially what the above is doing.