Page MenuHomePhorge

PHP 8.1 "strlen(null)" exception in PhutilOpaqueEnvelope.php
Closed, ResolvedPublic

Description

Fedora 38 machine with PHP 8.2.5. Just pulled Phorge; trying to set up a local Phorge test installation.

[ak@ac phorge]$ sudo ./phorge/bin/config set mysql.host "localhost"
[2023-04-21 23:59:19] EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=ca5f5cd1522c), phorge(head=master, ref.master=1ba5c8c26095)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/error/PhutilOpaqueEnvelope.php:63]
  #1 PhutilOpaqueEnvelope::mask(NULL, string) called at [<arcanist>/src/error/PhutilOpaqueEnvelope.php:35]
  #2 PhutilOpaqueEnvelope::__construct(NULL) called at [<phorge>/src/infrastructure/cluster/PhabricatorDatabaseRef.php:610]
  #3 PhabricatorDatabaseRef::newIndividualRef() called at [<phorge>/src/infrastructure/cluster/PhabricatorDatabaseRef.php:311]
  #4 PhabricatorDatabaseRef::getLiveIndividualRef() called at [<phorge>/src/infrastructure/cluster/PhabricatorDatabaseRef.php:538]
  #5 PhabricatorDatabaseRef::getAllMasterDatabaseRefs() called at [<phorge>/src/infrastructure/cluster/PhabricatorDatabaseRef.php:552]
  #6 PhabricatorDatabaseRef::getMasterDatabaseRefs() called at [<phorge>/src/infrastructure/env/PhabricatorEnv.php:235]
  #7 PhabricatorEnv::buildConfigurationSourceStack(boolean) called at [<phorge>/src/infrastructure/env/PhabricatorEnv.php:95]
  #8 PhabricatorEnv::initializeCommonEnvironment(boolean) called at [<phorge>/src/infrastructure/env/PhabricatorEnv.php:75]
  #9 PhabricatorEnv::initializeScriptEnvironment(boolean) called at [<phorge>/scripts/init/lib.php:26]
  #10 init_phabricator_script(array) called at [<phorge>/scripts/init/init-setup.php:9]
  #11 require_once(string) called at [<phorge>/scripts/setup/manage_config.php:5]

https://we.phorge.it/source/arcanist/browse/master/src/error/PhutilOpaqueEnvelope.php has the line
for ($ii = 0; $ii < strlen($string); $ii++) {
but $string might be empty.

Should probably have a surrounding if (phutil_nonempty_string($string)) check.