1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +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( array(
'name' => 'type', 'name' => 'type',
'param' => 'message-type', 'param' => 'message-type',
'default' => PhabricatorMailEmailMessage::MESSAGETYPE,
'help' => pht( 'help' => pht(
'Send the specified type of message (email, sms, ...).'), 'Send the specified type of message (email, sms, ...).'),
), ),
@ -74,10 +75,6 @@ final class PhabricatorMailManagementSendTestWorkflow
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$type = $args->getArg('type'); $type = $args->getArg('type');
if (!strlen($type)) {
$type = PhabricatorMailEmailMessage::MESSAGETYPE;
}
$type_map = PhabricatorMailExternalMessage::getAllMessageTypes(); $type_map = PhabricatorMailExternalMessage::getAllMessageTypes();
if (!isset($type_map[$type])) { if (!isset($type_map[$type])) {
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(

View file

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