Currently you cannot install media browser plus via drush which is probably because of the batch it starts after install.

I think we should move the batch to a cron or something the user has to do manually and just put up a message on install to run this cron in order to you older files.

Comments

ParisLiakos’s picture

Well 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?

c31ck’s picture

Status: Active » Needs review
StatusFileSize
new5.15 KB

I 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.

takki’s picture

Status: Needs review » Reviewed & tested by the community

The 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.

reubenavery’s picture

Status: Reviewed & tested by the community » Needs work

For 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.