Problem/Motivation
I get this error in the log after installing the module.
ValueError: array_chunk(): Argument #2 ($length) must be greater than 0 in array_chunk() (line 69 of /var/www/web/modules/contrib/trash/src/TrashEntityPurger.php)
#0 /var/www/web/modules/contrib/trash/src/TrashEntityPurger.php(69): array_chunk(Array, NULL)
#1 /var/www/web/modules/contrib/trash/src/TrashEntityPurger.php(90): Drupal\trash\TrashEntityPurger->populatePurgeQueue('file')
#2 /var/www/web/modules/contrib/trash/trash.module(323): Drupal\trash\TrashEntityPurger->cronPurge()
#3 /var/www/web/core/lib/Drupal/Core/Cron.php(335): trash_cron()
#4 /var/www/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Cron->Drupal\Core\{closure}(Object(Closure), 'trash')
#5 /var/www/web/core/lib/Drupal/Core/Cron.php(318): Drupal\Core\Extension\ModuleHandler->invokeAllWith('cron', Object(Closure))
#6 /var/www/web/core/lib/Drupal/Core/Cron.php(159): Drupal\Core\Cron->invokeCronHandlers()
#7 /var/www/web/core/lib/Drupal/Core/ProxyClass/Cron.php(75): Drupal\Core\Cron->run()
#8 /var/www/web/core/modules/automated_cron/src/EventSubscriber/AutomatedCron.php(65): Drupal\Core\ProxyClass\Cron->run()
#9 [internal function]: Drupal\automated_cron\EventSubscriber\AutomatedCron->onTerminate(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#10 /var/www/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#11 /var/www/vendor/symfony/http-kernel/HttpKernel.php(115): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\TerminateEvent), 'kernel.terminat...')
#12 /var/www/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(63): Symfony\Component\HttpKernel\HttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\JsonResponse))
#13 /var/www/web/core/lib/Drupal/Core/DrupalKernel.php(688): Drupal\Core\StackMiddleware\StackedHttpKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\JsonResponse))
#14 /var/www/web/index.php(22): Drupal\Core\DrupalKernel->terminate(Object(Symfony\Component\HttpFoundation\Request), Object(Symfony\Component\HttpFoundation\JsonResponse))
#15 {main}
Comments
Comment #2
sarwan_verma commentedHi @CNDexter,
I have fixed this issue "ValueError: array_chunk(): Argument #2 ($length) must be greater than 0 in array_chunk()" and also attached patch ,
please review and verify .
Comment #4
ayush.pandey commented@sarwan_verma , Can you please elaborate, how you reproduced this issue specifically, and if possible, any screenshots. For Drupal 10.3, the issue is not reproducible, with or without any content in the database. Installing the module works swiftly.
Comment #5
amateescu commentedHere's a patch that sets a default value for the
entity_update_batch_sizesetting, which might not exist in a site. Also added a safety check if there are no items to purge.However, the
auto_purge.enabledtrash setting isfalseinitially, and the only entity type that's enabled by default isnode.@CNDexter, are you sure that the error happened when installing the module? And if so, can you check if the
fileentity type already has adeletedfield?Comment #7
amateescu commentedI've committed the patch in #5 to 3.x, but I'm keeping the issue open in case there are any more details that can be shared.
Comment #8
cndexter commented@sarwan_verma @amateescu @ayush.pandey this was happening after install (not during). I noticed this error happened a bit after install, likely when files started getting moved to the trash. Otherwise it installs cleanly. I'm on 10.2.5 and it looks like the patch in #5 resolves the error. Thank you so very much!
Comment #9
amateescu commentedGlad to hear that, we can close this now.