Needs work
Project:
Media Browser Plus
Version:
7.x-2.x-dev
Component:
Code
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Mar 2012 at 09:39 UTC
Updated:
31 May 2012 at 15:21 UTC
Jump to comment: Most recent file
Comments
Comment #1
ParisLiakos commentedWell if you consider doing the import via cron you cant use Batch, but Queue
http://api.drupal.org/api/examples/queue_example--queue_example.module/7
But i guess it would be better to just let user run the import and just keep the existing code.Maybe a
drupal_set_message()after install that contains the url for the import to run?Comment #2
c31ck commentedI think we basically have two options here:
1. We continue to use Batch API and we wrap the import in a page callback. When the module is being enabled with drush, we show a message that the user needs to visit the import page to trigger the import of images.
2. We no longer use Batch API but use Queue API instead. Files will get moved during cron runs.
Attached is a patch that implements the second option: use Queue API.
Comment #3
takki commentedThe patch works as expected.
However when a lot of files need to be moved, it might take a couple of cron runs until all files are processed.
In this case maybe option 1 is the better option.
Comment #4
reubenavery commentedFor its purposes, this patch works.
However--
It should be taken into consideration that invoking the Batch API inside a hook_enable can interfere with other install tasks waiting behind. But-- Since this is a one-time maintenance thing, I don't think we should implement hook_cron. Rather, keep the Batch API but put invoking it inside an administrative screen.