Page MenuHomePhorge

Fix "Undefined offset: 1" exception in Diviner when @task value in PHPDoc is a single word
ClosedPublic

Authored by aklapper on Jun 11 2024, 09:40.
Tags
None
Referenced Files
F3749233: D25690.1745793803.diff
Sat, Apr 26, 22:43
F3749200: D25690.1745792253.diff
Sat, Apr 26, 22:17
F3711961: D25690.1745665337.diff
Fri, Apr 25, 11:02
F3702030: D25690.1745614849.diff
Thu, Apr 24, 21:00
F3695639: D25690.1745594866.diff
Thu, Apr 24, 15:27
F3647153: D25690.1745400038.diff
Tue, Apr 22, 09:20
F3605171: D25690.1745255493.diff
Sun, Apr 20, 17:11
F3604450: D25690.1745200577.diff
Sun, Apr 20, 01:56

Details

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

Diff Detail

Repository
rP Phorge
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

speck added inline comments.
src/applications/diviner/controller/DivinerAtomController.php
449–453

I can’t recall for php… I’d the double equals used to prevent coercion, in which case this would always be true if strpos doesn’t find anything?

src/applications/diviner/controller/DivinerAtomController.php
449–453

@speck: Hmm, not sure I can fully parse your comment, sorry. :)
Looking at "Return Values" in https://www.php.net/manual/en/function.strpos.php it says "Returns false if the needle was not found. [...] Use the === operator for testing the return value of this function." and in Example 2 "The !== operator can also be used." So I think this change works as expected to only call explode if a whitespace was found?

Not having a title seems j like a bug elsewhere

src/applications/diviner/controller/DivinerAtomController.php
449–453

Oof - you answered my question. I didn’t look it up but thought strpos returned and index and not boolean

This revision is now accepted and ready to land.Jun 22 2024, 03:00