PHP error "undefined offset"

Reproduction Instructions

Unfortunately I don’t know what the conditions are to reproduce this issue on any given installation.

I go to:

With Developer Mode on, I get the warning “this page raised errors” and I can see this error in the Dark Console:

Undefined offset: 1 at [DiffusionHistoryQueryConduitAPIMethod.php:155]
Undefined offset: 1
Stack trace:
DiffusionHistoryQueryConduitAPIMethod::getMercurialResult called at [/srv/www/ph.****.com/phabricator/src/applications/diffusion/conduit/DiffusionQueryConduitAPIMethod.php:159]
DiffusionQueryConduitAPIMethod::getResult called at [/srv/www/ph.****.com/phabricator/src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php:35]
DiffusionHistoryQueryConduitAPIMethod::getResult called at [/srv/www/ph.****.com/phabricator/src/applications/diffusion/conduit/DiffusionQueryConduitAPIMethod.php:147]
DiffusionQueryConduitAPIMethod::execute called at [/srv/www/ph.****.com/phabricator/src/applications/conduit/method/ConduitAPIMethod.php:123]
ConduitAPIMethod::executeMethod called at [/srv/www/ph.****.com/phabricator/src/applications/conduit/call/ConduitCall.php:131]
ConduitCall::executeMethod called at [/srv/www/ph.****.com/phabricator/src/applications/conduit/call/ConduitCall.php:81]
ConduitCall::execute called at [/srv/www/ph.****.com/phabricator/src/applications/diffusion/query/DiffusionQuery.php:82]
DiffusionQuery::callConduitWithDiffusionRequest called at [/srv/www/ph.****.com/phabricator/src/applications/diffusion/controller/DiffusionController.php:260]
DiffusionController::callConduitMethod called at [/srv/www/ph.****.com/phabricator/src/applications/diffusion/controller/DiffusionRepositoryController.php:200]
DiffusionRepositoryController::buildNormalContent called at [/srv/www/ph.****.com/phabricator/src/applications/diffusion/controller/DiffusionRepositoryController.php:102]
DiffusionRepositoryController::handleRequest called at [/srv/www/ph.****.com/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:286]
AphrontApplicationConfiguration::processRequest called at [/srv/www/ph.****.com/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:206]
AphrontApplicationConfiguration::runHTTPRequest called at [/srv/www/ph.****.com/phabricator/webroot/index.php:35]

Other than that (without developer mode I wouldn’t even see the error), the page looks almost fine, except for this:

Note the “couldn’t wri” instead of the commit ID.

No matter what the underlying cause of the error is, which is almost surely not in Phabricator, these two things are certainly bugs in Phabricator:

  • the PHP notice “undefined offset” (clearly some check is missing)
  • the string “couldn’t wri” displayed where a commit ID should be

I don’t know whether the two things are related, it seems plausible.

Even without being able to reproduce the issue, I think it should be possible to fix the bug (at tleast the PHP notice, if the other is not directly related) with this information by checking for the existence of the index in the array before you access it.

Phabricator/Arcanist Version
Output from Config > Version Information or arc version.

phabricator54bcbdaba94a3573e128c6498816dbfa41d3a9cb (Fri, Dec 13)arcanist3cdfe1fff806d2b54a2df631cf90193e518f42b7 (Sep 5 2019)phutilf51f1b3f72b50246949d0917239ca84f39ec7a54 (Sep 2 2019)php7.3.11-1~deb10u1diff3.7 at /usr/bin/diffgit2.20.1 at /usr/bin/githg4.8.2 at /usr/bin/hgpygmentize2.5.2 at /usr/local/bin/pygmentizesvnNot Available

Actually that branch whose supposed commit can be seen at the bottom that says “couldn’t wri” doesn’t exist.
I see the same at the bottom of every single repo (I have 9). See for example this repo whose whole history is just two commits:
The importing one at the bottom is bogus.


phabricator# bin/repository importing RN

always returns “No importing commits found.” for every N. Which is what I would expect since everything had already been imported before I migrated the installation to the new server.

Again, there might well be something wrong in my setup, but the observed behavior is wrong regardless.

After pushing a commit to one of the repos, both issues disappeared for that repo (meaning both the PHP notice and the bogus orphan broken commit at the bottom of the history). It only “fixed” the issue for the repo I pushed to.