The nodes are created, even though there is an error. Versions:

$ drush en devel devel_generate -y && drush genc 50;
[success] Successfully enabled: devel, devel_generate
[status] Finished creating 50 nodes
[status] Generate process complete.
[warning] Invalid argument supplied for foreach() batch.inc:133
[error]  Error: Call to a member function claimItem() on null in _drush_batch_worker() (line 218 of /var/www/public/mysite/vendor/drush/drush/includes/batch.inc)
#0 /var/www/public/mysite/vendor/drush/drush/includes/batch.inc(183): _drush_batch_worker()
#1 /var/www/public/mysite/vendor/drush/drush/includes/batch.inc(95): _drush_batch_command('2')
#2 /var/www/public/mysite/vendor/drush/drush/src/Drupal/Commands/core/BatchCommands.php(19): drush_batch_command('2')
#3 [internal function]: Drush\Drupal\Commands\core\BatchCommands->process('2', Array)
#4 /var/www/public/mysite/vendor/consolidation/annotated-command/src/CommandProcessor.php(235): call_user_func_array(Array, Array)
#5 /var/www/public/mysite/vendor/consolidation/annotated-command/src/CommandProcessor.php(181): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#6 /var/www/public/mysite/vendor/consolidation/annotated-command/src/CommandProcessor.php(147): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#7 /var/www/public/mysite/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(404): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#8 /var/www/public/mysite/vendor/symfony/console/Command/Command.php(264): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/public/mysite/vendor/symfony/console/Application.php(859): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/public/mysite/vendor/symfony/console/Application.php(206): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/public/mysite/vendor/symfony/console/Application.php(125): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/public/mysite/vendor/drush/drush/src/Runtime/Runtime.php(112): Symfony\Component\Console\Application->run(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/public/mysite/vendor/drush/drush/src/Runtime/Runtime.php(41): Drush\Runtime\Runtime->doRun(Array)
#14 /var/www/public/mysite/vendor/drush/drush/drush.php(64): Drush\Runtime\Runtime->run(Array)
#15 /var/www/public/mysite/vendor/drush/drush/includes/preflight.inc(17): require('/var/www/public...')
#16 phar:///usr/local/bin/drush/bin/drush.php(137): drush_main()
#17 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#18 {main}.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ressa created an issue. See original summary.

shrop’s picture

I am seeing the same issue, but the first run generated the error below for each node that was attempted to be created. No nodes were created:

 [warning] array_filter() expects parameter 1 to be array, null given ContentDevelGenerate.php:453
 [warning] array_rand() expects parameter 1 to be array, null given ContentDevelGenerate.php:453
 [warning] array_rand() expects parameter 1 to be array, null given ContentDevelGenerate.php:454
 [warning] mt_rand(): max(0) is smaller than min(1) ContentDevelGenerate.php:459
 [warning] array_rand(): Second argument has to be between 1 and the number of elements in the array Random.php:241
 [error]  Missing bundle for entity type node
unqunq’s picture

I can replicate with Drupal: 8.5.0, Drush: 9.2.1 Devel: 8.x-1.2.
I can generate terms fine. This pops up when I try to generate nodes of a custom content type which works fine via the UI.

[warning] Invalid argument supplied for foreach() batch.inc:133
 [error]  Error: Call to a member function claimItem() on null in _drush_batch_worker() (line 218 of /var/www/html/vendor/drush/drush/includes/batch.inc) #0 /var/www/html/vendor/drush/drush/includes/batch.inc(183): _drush_batch_worker()
#1 /var/www/html/vendor/drush/drush/includes/batch.inc(95): _drush_batch_command('14')
#2 /var/www/html/vendor/drush/drush/src/Drupal/Commands/core/BatchCommands.php(19): drush_batch_command('14')
#3 [internal function]: Drush\Drupal\Commands\core\BatchCommands->process('14', Array)
#4 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(235): call_user_func_array(Array, Array)
#5 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(181): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#6 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(150): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#7 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(404): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#8 /var/www/html/vendor/symfony/console/Command/Command.php(252): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/html/vendor/symfony/console/Application.php(964): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(112): Symfony\Component\Console\Application->run(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(41): Drush\Runtime\Runtime->doRun(Array)
#14 /var/www/html/vendor/drush/drush/drush.php(64): Drush\Runtime\Runtime->run(Array)
#15 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...')
#16 {main}. 
Prashant.c’s picture

Status: Active » Needs review

I have Drush version 8.0.1 and Drupal version 8.6.x, Devel Version 8.x-1.x and command drush genc 50 worked fine, it created 50 nodes successfully.

In case of #1, #2 and #3 it could be an issue with the Drush 9 only.

imperator_99’s picture

I get the same error with Drush 9.3.0, Drupal 8.5.4 and Devel 8.x-1.2. Nodes get created, however. I generated 10 nodes.

Cheers,
Jesse.

brayfe’s picture

I get the exact same error as well when using Drupal 8.5.4, Drush 9.3.0 and Devel 8.x-1.2. Nodes are created, but this error is thrown. Since I'm using BLT, I cannot downgrade drush to the 8.x version. It would be great of someone else could test it with Drush 8.

Amacado’s picture

Same issue here:

 [warning] array_filter() expects parameter 1 to be array, null given ContentDevelGenerate.php:453
 [warning] array_rand() expects parameter 1 to be array, null given ContentDevelGenerate.php:453
 [warning] array_rand() expects parameter 1 to be array, null given ContentDevelGenerate.php:454
 [warning] mt_rand(): max(0) is smaller than min(1) ContentDevelGenerate.php:459
 [warning] array_rand(): Second argument has to be between 1 and the number of elements in the array Random.php:241
 [error]  Missing bundle for entity type node

drush 9.3.0
drupal 8.5.6
devel 8.x-1.2

I tried downgrade to drush 8.1.17. Note when downgrading from drush 9 you will run into a PHP Fatal error: Class 'Drush\Commands\DrushCommands' not found in /var/www/html/path-to-site/drush/Commands/PolicyCommands.php error. You can fix that when remove/rename the PolicyCommands.php file (https://github.com/drush-ops/drush/issues/3456). For example like this:
mv drush/Commands/PolicyCommands.php drush/Commands/PolicyCommands.php.bak

After solving this problem i got into the error Missing argument 2 for Drush\Sql\SqlBase::__construct() SqlBase.php:34 which i could not resolve.

rfsbsb’s picture

I confirm I'm having the same error with:

Drush Launcher Version: 0.6.0
Drush Launcher Version: 0.6.0
Drush Commandline Tool 9.3.0
PHP: 7.1.21
Drupal: 8.5.5

ressa’s picture

Status: Needs review » Needs work

Still an issue:

Drupal version  : 8.6.3                             
Drush version   : 9.5.2       
Devel (devel)   : 8.x-1.2   
ressa’s picture

RoSk0’s picture

Version: 8.x-1.2 » 8.x-2.x-dev

Still present:

Drupal version: 8.6.13
Drush version: 9.5.2
Devel: 8.x-2.0

DuaelFr’s picture

Status: Needs work » Needs review
FileSize
557 bytes

The issue occurs because drush_backend_batch_process() is ran twice.
Here is a patch. Reviews welcome!

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Right you are. Merged.

ressa’s picture

Status: Reviewed & tested by the community » Needs review

I no longer get the error, thanks @DuaelFr and @moshe weitzman! It looks like there has been a lot of improvements (including this one) since 8.x-2.0, so perhaps a fresh release is worth considering?

ressa’s picture

Status: Needs review » Reviewed & tested by the community

Not sure why it changed Status ...

DuaelFr’s picture

Status: Reviewed & tested by the community » Fixed

Thanks a lot!
I supposed you wanted to mark the issue as "Fixed" :)

Status: Fixed » Closed (fixed)

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