Problem/Motivation

With Drush 13.6.2 after enabling the module along with a module implementing a plugin, and even after repeated cache reloads, trying to run drush batch_plugin:process anything returns 'There are no commands defined in the "batch_plugin" namespace.' and trying to run drush bpp returns "Command "bpp" is not defined."

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mlncn created an issue. See original summary.

mlncn’s picture

Title: Drush command not found » Drush command not found with Drush 13
Version: 2.0.3 » 2.0.x-dev

Ah, Drush 13 changed things up: "Drush 13 expects commandfiles to use Autowire to inject Drupal and Drush dependencies. Prior versions used a drush.services.yml file which is now deprecated and will be removed in Drush 13."

https://www.drush.org/13.0.0/commands/

mlncn’s picture

Assigned: Unassigned » mlncn
mlncn’s picture

Assigned: mlncn » Unassigned
Status: Active » Needs review

The commands can be seen and run. The main need seemed to be the drush.services.yml, which is not supposed to be needed since Drush 13, but there is documentation and then there is what actually works. I'm still getting errors ("> [warning] Undefined array key "success" batch.inc:229; [error] Error: Call to a member function claimItem() on null in _drush_batch_worker() (line 242 of /var/www/html/vendor/drush/drush/includes/batch.inc) #0 /var/www/html/vendor/drush/drush/includes/batch.inc(204): _drush_batch_worker()"), but that might be with my plugin not the new Drush implementation.

dubs’s picture

@mlncn - thanks for forking and fixing this. I've merged a modified version of your code which used a trait to allow support for older versions of drush.

I can't see anything wrong with your plugin code. The error suggests that the item isn't there, which is odd.

Try running this command (enable the example module), and let me know if you get the same issues. If you do, feel free to open a new issue.

drush batch_plugin:process example_drush_batch_plugin

I've tested here on a sandbox and a few sites we have live with this, and it's all good with no errors or warnings.

Thanks again for the fix!

dubs’s picture

Status: Needs review » Fixed
dubs’s picture

Status: Fixed » Closed (fixed)
dubs’s picture

@mlncn, so I couldn't help myself and downloaded your module. Tested it and I got the same error. It's because $this->operations was an empty array. I've fixed that in the Cron processor. Checkout version 2.0.5 :-)