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}

Issue fork trash-3460865

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

CNDexter created an issue. See original summary.

sarwan_verma’s picture

Status: Active » Needs review
StatusFileSize
new728 bytes

Hi @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 .

ananya.k made their first commit to this issue’s fork.

ayush.pandey’s picture

StatusFileSize
new932.36 KB

@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.

amateescu’s picture

StatusFileSize
new1.41 KB

Here's a patch that sets a default value for the entity_update_batch_size setting, which might not exist in a site. Also added a safety check if there are no items to purge.

However, the auto_purge.enabled trash setting is false initially, and the only entity type that's enabled by default is node.

@CNDexter, are you sure that the error happened when installing the module? And if so, can you check if the file entity type already has a deleted field?

  • amateescu committed 24cbcf80 on 3.x
    Issue #3460865 by sarwan_verma, amateescu, CNDexter: ValueError:...
amateescu’s picture

Version: 3.0.4 » 3.x-dev
Status: Needs review » Postponed (maintainer needs more info)

I'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.

cndexter’s picture

StatusFileSize
new624.55 KB

@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!

amateescu’s picture

Status: Postponed (maintainer needs more info) » Fixed

Glad to hear that, we can close this now.

Status: Fixed » Closed (fixed)

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