Using Batch API in hook_install
Hi all, Is using Batch API from hook_install discouraged? On installation, my module retrieves 9 files from the Web, parses them, and enters some information into the database. I wanted to use Batch API to do this. It is working in the Web interface, but when I try to enable my module with Drush, I get the following error WD php: Warning: Cannot modify header information - headers already sent by (output started at /drush/includes/drush.inc:797) in drupal_goto() (line 677 of /drupal-head/includes/common.inc). I wanted to use Batch API because some people with slower connections might have timeout problems when retrieving the files and because it is a neat way to tell the user what is happening. Is there another way I should be doing this? Thanks, Lin -- Lin Clark DERI, NUI Galway <http://www.deri.ie/> lin-clark.com twitter.com/linclark
Alternatively you could have post-install drupal_set_message() that prompts the user to visit call the batch operation manually (similar to when content access permissions need to be rebuilt via admin/content/node-settings). Use variable_get()/variable_set() once the batch has run to disable the message. On Wed, Sep 29, 2010 at 12:44 PM, Lin Clark <lin.w.clark@gmail.com> wrote:
Hi all,
Is using Batch API from hook_install discouraged?
On installation, my module retrieves 9 files from the Web, parses them, and enters some information into the database. I wanted to use Batch API to do this.
It is working in the Web interface, but when I try to enable my module with Drush, I get the following error WD php: Warning: Cannot modify header information - headers already sent by
(output started at /drush/includes/drush.inc:797) in drupal_goto() (line 677 of /drupal-head/includes/common.inc).
I wanted to use Batch API because some people with slower connections might have timeout problems when retrieving the files and because it is a neat way to tell the user what is happening.
Is there another way I should be doing this?
Thanks, Lin
-- Lin Clark DERI, NUI Galway <http://www.deri.ie/>
lin-clark.com twitter.com/linclark
participants (2)
-
Carl Wiedemann -
Lin Clark