Submissionchecklist

Describe the issue or problem
When submission checklist is empty, it is not possible to add a new item.

php8 also return a fatal error

Steps I took leading up to the issue

  1. go to workflow for a journal
  2. go to submission checklist
  3. delete all items if any left
  4. add new item

What application are you using?
OJS 3.3.0-14

Additional information
I made this patch to make it work. So maybe it could be solved in next version.

For some reason after an upgrade from 3.1 some checklists was empty. Seems to be because of order not starting from 1 (Those where reentered to solve it). Some also had wrong format (Could be solved by refreshing checklist in old version)

The patch :

--- ./lib/pkp/controllers/grid/settings/submissionChecklist/form/SubmissionChecklistForm.inc.php_org    2023-03-21 14:21:34.143530685 +0100
+++ ./lib/pkp/controllers/grid/settings/submissionChecklist/form/SubmissionChecklistForm.inc.php        2023-03-23 17:36:02.062571723 +0100
@@ -93,28 +93,36 @@
                $router = $request->getRouter();
                $context = $router->getContext($request);
                $submissionChecklistAll = $context->getData('submissionChecklist');
-               $locale = AppLocale::getPrimaryLocale();
-               //FIXME: a bit of kludge to get unique submissionChecklist id's
-               $this->submissionChecklistId = ($this->submissionChecklistId != null ? $this->submissionChecklistId:(max(array_keys($submissionChecklistAll[$locale])) + 1));
+    $order = 0;
+    // PHP 8 fix
+    // Fixes adding an checklist item when no items left
+    $locale = AppLocale::getPrimaryLocale();
+    if (isset($submissionChecklistAll[$locale]) && !empty($submissionChecklistAll[$locale]) ) {
+      //FIXME: a bit of kludge to get unique submissionChecklist id's
+      $this->submissionChecklistId = ($this->submissionChecklistId != null ? $this->submissionChecklistId:(max(array_keys($submissionChecklistAll[$locale])) + 1));
+      foreach ($submissionChecklistAll[$locale] as $checklistItem) {
+        if ($checklistItem['order'] > $order) {
+          $order = $checklistItem['order'];
+        }
+      }
 
-               $order = 0;
-               foreach ($submissionChecklistAll[$locale] as $checklistItem) {
-                       if ($checklistItem['order'] > $order) {
-                               $order = $checklistItem['order'];
-                       }
-               }
-               $order++;
+    } else {
+      $this->submissionChecklistId = ($this->submissionChecklistId ?? 1);
+    }
 
-               $checklistItem = $this->getData('checklistItem');
-               foreach (AppLocale::getSupportedLocales() as $locale => $name) {
-                       if (isset($checklistItem[$locale])) {
-                               $submissionChecklistAll[$locale][$this->submissionChecklistId]['content'] = $checklistItem[$locale];
-                               $submissionChecklistAll[$locale][$this->submissionChecklistId]['order'] = $order;
-                       }
-               }
+    $order++;
+
+    $checklistItem = $this->getData('checklistItem');
+    foreach (AppLocale::getSupportedLocales() as $locale => $name) {
+      if (isset($checklistItem[$locale])) {
+        $submissionChecklistAll[$locale][$this->submissionChecklistId]['content'] = $checklistItem[$locale];
+        $submissionChecklistAll[$locale][$this->submissionChecklistId]['order'] = $order;
+      }
+    }
+
+    $context->updateSetting('submissionChecklist', $submissionChecklistAll, 'object', true);
+    parent::execute(...$functionArgs);
 
-               $context->updateSetting('submissionChecklist', $submissionChecklistAll, 'object', true);
-               parent::execute(...$functionArgs);
                return true;
        }
 }