1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

fix strlen in PhabricatorMailManagementShowOutboundWorkflow

Summary: Ref T15064

Test Plan: run `./bin/mail show-outbound --id 1` on a non-html email with php 8.1, no crash.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Tags: #php_8_support

Maniphest Tasks: T15064

Differential Revision: https://we.phorge.it/D25275
This commit is contained in:
Aviv Eyal 2023-07-02 08:47:59 -07:00
parent aebd7a2f72
commit 9aafbb42ef
2 changed files with 4 additions and 7 deletions

View file

@ -63,6 +63,7 @@ final class PhabricatorMailManagementSendTestWorkflow
array(
'name' => 'type',
'param' => 'message-type',
'default' => PhabricatorMailEmailMessage::MESSAGETYPE,
'help' => pht(
'Send the specified type of message (email, sms, ...).'),
),
@ -74,10 +75,6 @@ final class PhabricatorMailManagementSendTestWorkflow
$viewer = $this->getViewer();
$type = $args->getArg('type');
if (!strlen($type)) {
$type = PhabricatorMailEmailMessage::MESSAGETYPE;
}
$type_map = PhabricatorMailExternalMessage::getAllMessageTypes();
if (!isset($type_map[$type])) {
throw new PhutilArgumentUsageException(

View file

@ -65,7 +65,7 @@ final class PhabricatorMailManagementShowOutboundWorkflow
foreach ($messages as $message_key => $message) {
if ($args->getArg('dump-html')) {
$html_body = $message->getHTMLBody();
if (strlen($html_body)) {
if (phutil_nonempty_string($html_body)) {
$template =
"<!doctype html><html><body>{$html_body}</body></html>";
$console->writeOut("%s\n", $html_body);
@ -188,7 +188,7 @@ final class PhabricatorMailManagementShowOutboundWorkflow
$info[] = null;
$info[] = $this->newSectionHeader(pht('TEXT BODY'));
if (strlen($message->getBody())) {
if (phutil_nonempty_string($message->getBody())) {
$info[] = tsprintf('%B', $message->getBody());
} else {
$info[] = pht('(This message has no text body.)');
@ -203,7 +203,7 @@ final class PhabricatorMailManagementShowOutboundWorkflow
$info[] = null;
$info[] = $this->newSectionHeader(pht('HTML BODY'));
if (strlen($message->getHTMLBody())) {
if (phutil_nonempty_string($message->getHTMLBody())) {
$info[] = $message->getHTMLBody();
$info[] = null;
} else {