-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drush_backend_batch_process() and &$context #5009
Comments
Same issue here. I'm on 10.6.1 Drush version. What I've noticed is that after the first interaction, it's loosing the |
Sounds like a bug to me. Not expected. |
Getting the same here on 10.6.2. It's not passing the context between operations and the finish callback. |
FYI Drush 10 is no longer supported https://www.drush.org/latest/install/#drupal-compatibility. @ultimike do you recall what version of Drush you were using? |
Thanks @weitzman, I upgraded to 11.0.9 and the issue still persists. |
@weitzman When I posted this issue, I was running 11.0.5. I have since updated to 11.0.9 and the problem persists 🙁 -mike |
I have added test coverage which shows that $results is populated. $results is the 2nd param in a finished callback. See #5144 Not sure why others are seeing differently. Can you share your batch code? FWIW I looked at https://git.drupalcode.org/project/examples/-/blob/3.x/modules/batch_example/batch_example.module to see how batches are implemented. |
@weitzman Here's the relevant (I believe) code (some names have been changed to protect the innocent):
and
and
and
I think that's everything related - let me know if you need more - and thanks! -mike |
All I can see |
@weitzman Thanks for taking a look at it. I've removed the I spent a few minutes stepping through things using xdebug and it is clear that each time I have a question and this may be a result of the issue rather than the cause of the issue, but I'm still curious. In
At the very least, I am expecting to see the initialized version of the It seems that whatever I set When I set the values of thanks, |
How about putting a breakpoint in https://github.com/drush-ops/drush/blob/11.x/src/Drupal/Commands/core/BatchCommands.php#L20. That is where each batch gets worked. The line after it is where output is printed. Thats whats read by |
Hmm, doing as you suggested, stepping through the code,
But, this led me down the path of taking another look at how I initialize the In
I went back and looked at the sample code in the Examples module and didn't see anything similar so I suspected that this was the issue. Changing it to the following fixed my issue:
thanks! |
@ultimike @weitzman this is actually an issue. Could you please reopen it? I'm using one batch process + sandbox to split the operations in my scenario. If the sandbox items are less than the maximum size, I still face the issue - even if I apply something similar to what @ultimike suggested. I spent some time debugging this issue and I figured out that the problem happens in the following line:
This is basically changing the type of
The A PR has been created to fix it: #5354 |
Is there any way to make this work also on Drupal 9. Because it seems, I can't use Drush 12 with drupal9. And I can't update my website to Drupal 10 yet because of some dependencies in my modules. |
@DamienMrtl, there is always an option to add the patch to your composer package. |
The patch from #5354 does not apply to 11.6.0 so I'm attaching a re-rolled patch. |
I have a batch that runs fine via a form - with the $context being populated and
$context['results']
available to my "finished" callback as expected.I've created a custom Drush command for this batch, but when I run it with
drush_backend_batch_process();
, the$results
array isn't populated as I expect in my "finished" callback. Everything else is working fine - the custom Drush command runs the batch with the expected results, other than the$results
array being provided to the "finished" callback.Is this a known limitation of
drush_backend_batch_process();
or am I just missing something?thanks,
-mike
The text was updated successfully, but these errors were encountered: