Page MenuHomePhorge

Fix PHP 8.1 "strlen(null)" exception in PhabricatorMailSMTPAdapter when sending email
Closed, ResolvedPublic

Description

Summary:
strlen() was used in Phabricator to check if a generic value is a non-empty string.
This behavior is deprecated since PHP 8.1. Phorge adopts phutil_nonempty_string() as a replacement.

ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/htdocs/phorge/phorge/src/applications/metamta/adapter/PhabricatorMailSMTPAdapter.php:65]
Stack trace
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] [2024-06-15 12:07:25] ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/var/www/htdocs/phorge/phorge/src/applications/metamta/adapter/PhabricatorMailSMTPAdapter.php:65]
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] arcanist(head=master, ref.master=f7fcf31c7e23), diagram(head=master, ref.master=ce4b81b3705c), example(), ldapgrouppolicyrule(), light-rtl(head=master, ref.master=741e2946b93f), phorge(head=master, ref.master=1bb7422662ac, custom=1), tafula(head=master), templateliterals()
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] #0 PhabricatorMailSMTPAdapter::sendMessage(PhabricatorMailEmailMessage) called at [<phorge>/src/applications/metamta/storage/PhabricatorMetaMTAMail.php:750]
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] #1 PhabricatorMetaMTAMail::sendWithMailers(array) called at [<phorge>/src/applications/metamta/storage/PhabricatorMetaMTAMail.php:555]
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] #2 PhabricatorMetaMTAMail::sendNow() called at [<phorge>/src/applications/metamta/PhabricatorMetaMTAWorker.php:22]
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] #3 PhabricatorMetaMTAWorker::doWork() called at [<phorge>/src/infrastructure/daemon/workers/PhabricatorWorker.php:124]
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] #4 PhabricatorWorker::executeTask() called at [<phorge>/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php:160]
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] #5 PhabricatorWorkerActiveTask::executeTask() called at [<phorge>/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php:22]
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] #6 PhabricatorTaskmasterDaemon::run() called at [<phorge>/src/infrastructure/daemon/PhutilDaemon.php:216]
Daemon 2522 STDE [Sat, 15 Jun 2024 12:07:26 +0000] #7 PhutilDaemon::execute() called at [<phorge>/scripts/daemon/exec/exec_daemon.php:131]