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
F2943258: D25690.1738172380.diff
Tue, Jan 28, 17:39
F2942993: D25690.1738153833.diff
Tue, Jan 28, 12:30
F2942368: D25690.1738117104.diff
Tue, Jan 28, 02:18
F2940256: D25690.1738046245.diff
Mon, Jan 27, 06:37
F2933074: D25690.1737750991.diff
Thu, Jan 23, 20:36
F2933073: D25690.1737750989.diff
Thu, Jan 23, 20:36
F2932886: D25690.1737745664.diff
Thu, Jan 23, 19:07
F2888940: D25690.1737196729.diff
Fri, Jan 17, 10:38

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