From ddcdd6eaf24be694588bd792e2c2c47b493e3388 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Tue, 11 Jun 2024 11:39:46 +0200 Subject: [PATCH] Fix "Undefined offset: 1" exception in Diviner when @task value in PHPDoc is a single word Summary: The PHPDoc in https://we.phorge.it/source/phorge/browse/master/src/infrastructure/storage/lisk/LiskMigrationIterator.php$14 defines `* @task storage`. That means the value of `$task` in the DivinerAtomController class is the single string `storage` and there is no whitespace to `explode` on and there is no second key in the array to set as `$title`. Thus only call `explode` when `$task` contains a whitespace. ``` EXCEPTION: (RuntimeException) Undefined array key 1 at [/src/error/PhutilErrorHandler.php:273] #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [/src/applications/diviner/controller/DivinerAtomController.php:450] ``` Closes T15854 Test Plan: Go to https://we.phorge.it/book/contrib/article/database/#primary-keys and click the `LiskMigrationIterator` link pointing to https://we.phorge.it/book/dev/class/LiskMigrationIterator/ Reviewers: O1 Blessed Committers, speck Reviewed By: O1 Blessed Committers, speck Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15854 Differential Revision: https://we.phorge.it/D25690 --- .../diviner/controller/DivinerAtomController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/applications/diviner/controller/DivinerAtomController.php b/src/applications/diviner/controller/DivinerAtomController.php index cf29389da9..100fe0f354 100644 --- a/src/applications/diviner/controller/DivinerAtomController.php +++ b/src/applications/diviner/controller/DivinerAtomController.php @@ -446,7 +446,11 @@ final class DivinerAtomController extends DivinerController { if ($tasks) { foreach ($tasks as $task) { - list($name, $title) = explode(' ', $task, 2); + if (strpos($task, ' ') !== false) { + list($name, $title) = explode(' ', $task, 2); + } else { + list($name, $title) = array($task, ''); + } $name = trim($name); $title = trim($title);