Division by zero possibility in OperationsBase

Created on 5 August 2024, 5 months ago
Updated 12 August 2024, 4 months ago

Problem/Motivation

In the case of a script that doesn't have a determinable number of items to gather, such as when you are both creating nodes and processing them, you can run into a division by zero issue in OperationsBase.php:

 $vars = [
      '@last_item_completed' => is_null($last_item_completed) ? $this->t('unknown') : $last_item_completed,
      '@total_items' => is_null($total_items) ? $this->t('unknown') : $total_items,
      '@percent' => is_null($total_items ? $this->t('unknown') : round(($last_item_completed / $total_items) * 100),
      '@units' => $this->t('items processed'),
    ];

Steps to reproduce

  • Create a script that makes nodes in the gatherItemsToProcess() method.
  • Make sure that it returns 0
  • Go to /admin/config/development/batch_operations/operations
  • Get the error

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States skyriter

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024