If you execute a drush command that invokes drush_backend_batch_process() as a user other than 0 (i.e. drush -u 1 foo_command) the logged in user will not be passed off to the batch command. This can result in inconsistent batch behavior. Specifically I saw this with a batch process that my custom drush command executed to delete nodes.

I have attached a patch that fixes this issue, but in the meantime anyone that needs to do this can change the way they call drush_backend_batch_process() like this:

<?php
  // ...
  global $user;
  drush_backend_batch_process('batch-process -u ' . $user->uid);
?>
CommentFileSizeAuthor
drush.patch2.08 KBelliotttf

Comments

greg.1.anderson’s picture

The code looks good (reviewed but not tested). I don't think there is any code path in drush core to test this, but I am not opposed to committing.

moshe weitzman’s picture

Status: Needs review » Fixed

Looks good to me too. Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.