1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

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 [<arcanist>/src/error/PhutilErrorHandler.php:273]
  #0 <#2> PhutilErrorHandler::handleError(integer, string, string, integer) called at [<phorge>/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
This commit is contained in:
Andre Klapper 2024-06-11 11:39:46 +02:00
parent 1f5c54c35a
commit ddcdd6eaf2

View file

@ -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);