From 9aafbb42ef8d33437696c4b55fc24ea1de0a3da9 Mon Sep 17 00:00:00 2001 From: Aviv Eyal Date: Sun, 2 Jul 2023 08:47:59 -0700 Subject: [PATCH] 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 --- .../PhabricatorMailManagementSendTestWorkflow.php | 5 +---- .../PhabricatorMailManagementShowOutboundWorkflow.php | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php b/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php index f390ff27df..6ea2c9de5a 100644 --- a/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php +++ b/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php @@ -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( diff --git a/src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php b/src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php index f29a63c2eb..1f4f5a3e2a 100644 --- a/src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php +++ b/src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php @@ -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 = "{$html_body}"; $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 {