@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

+4 -7
+1 -4
src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php
··· 63 63 array( 64 64 'name' => 'type', 65 65 'param' => 'message-type', 66 + 'default' => PhabricatorMailEmailMessage::MESSAGETYPE, 66 67 'help' => pht( 67 68 'Send the specified type of message (email, sms, ...).'), 68 69 ), ··· 74 75 $viewer = $this->getViewer(); 75 76 76 77 $type = $args->getArg('type'); 77 - if (!strlen($type)) { 78 - $type = PhabricatorMailEmailMessage::MESSAGETYPE; 79 - } 80 - 81 78 $type_map = PhabricatorMailExternalMessage::getAllMessageTypes(); 82 79 if (!isset($type_map[$type])) { 83 80 throw new PhutilArgumentUsageException(
+3 -3
src/applications/metamta/management/PhabricatorMailManagementShowOutboundWorkflow.php
··· 65 65 foreach ($messages as $message_key => $message) { 66 66 if ($args->getArg('dump-html')) { 67 67 $html_body = $message->getHTMLBody(); 68 - if (strlen($html_body)) { 68 + if (phutil_nonempty_string($html_body)) { 69 69 $template = 70 70 "<!doctype html><html><body>{$html_body}</body></html>"; 71 71 $console->writeOut("%s\n", $html_body); ··· 188 188 189 189 $info[] = null; 190 190 $info[] = $this->newSectionHeader(pht('TEXT BODY')); 191 - if (strlen($message->getBody())) { 191 + if (phutil_nonempty_string($message->getBody())) { 192 192 $info[] = tsprintf('%B', $message->getBody()); 193 193 } else { 194 194 $info[] = pht('(This message has no text body.)'); ··· 203 203 204 204 $info[] = null; 205 205 $info[] = $this->newSectionHeader(pht('HTML BODY')); 206 - if (strlen($message->getHTMLBody())) { 206 + if (phutil_nonempty_string($message->getHTMLBody())) { 207 207 $info[] = $message->getHTMLBody(); 208 208 $info[] = null; 209 209 } else {