Skip to content

Commit 186768c

Browse files
committed
Fix PHP 8.1 "strlen(null)" exception when received email lacks From header
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. Note: this may highlight other absurd input values that might be worth correcting instead of just ignoring. If phutil_nonempty_string() throws an exception in your instance, report it to Phorge to evaluate and fix that specific corner case. ``` ERROR 8192: strlen(): Passing null to parameter freebsd#1 ($string) of type string is deprecated at [/var/www/html/phorge/phorge/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php:527] ``` Closes T15767 Test Plan: See T15767 Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15767 Differential Revision: https://we.phorge.it/D25564
1 parent 5263d5d commit 186768c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public function newContentSource() {
524524
public function newFromAddress() {
525525
$raw_from = $this->getHeader('From');
526526

527-
if (strlen($raw_from)) {
527+
if (phutil_nonempty_string($raw_from)) {
528528
return new PhutilEmailAddress($raw_from);
529529
}
530530

0 commit comments

Comments
 (0)