open-y-subprojects/openy_features

Add guards to program, subcategory and activity batch updates

Closed this issue · 3 comments

Hi! I saved a program subcategory and received the following error. I believe it's because there were no associated activities.

TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/html/web/modules/contrib/openy_features/openy_node/src/BatchNodeUpdate.php on line 82 #0 /var/www/html/web/modules/contrib/openy_features/openy_node/src/BatchNodeUpdate.php(82): count(NULL)"
#1 /var/www/html/web/core/includes/batch.inc(456): Drupal\openy_node\BatchNodeUpdate::finished(true, Array, Array, Object(Drupal\Core\StringTranslation\TranslatableMarkup))"
#2 /var/www/html/web/core/includes/batch.inc(98): _batch_finished()"
#3 /var/www/html/web/core/modules/system/src/Controller/BatchController.php(55): _batch_page(Object(Symfony\Component\HttpFoundation\Request))"
#4 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request))"
#5 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)"
#6 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer..."

Btw this is a complete tangent, but I was wondering about using batch_set() in a hook_node_update(): will the batch be processed if you update a node programmatically rather than via a form?

Merged, thank you

Btw this is a complete tangent, but I was wondering about using batch_set() in a hook_node_update(): will the batch be processed if you update a node programmatically rather than via a form?

yes, batch works in programmatically node->save() contexts