From b3557796fe6552612fc32ff91eb47049fd3ae64c Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 25 Apr 2022 11:36:02 -0700 Subject: [PATCH] Remove product literal strings in "pht()", part 6 Summary: Ref T13658. Test Plan: This test plan is non-exhaustive. - Ran `bin/mail`. - Uninstalled and reinstalled an application. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13658 Differential Revision: https://secure.phabricator.com/D21770 --- .../query/HarbormasterBuildPlanQuery.php | 2 +- ...masterUploadArtifactBuildStepImplementation.php | 2 +- .../legalpad/editor/LegalpadDocumentEditEngine.php | 2 +- .../config/PhabricatorManiphestConfigOptions.php | 2 +- .../PhabricatorApplicationUninstallController.php | 11 ++++---- .../metamta/adapter/PhabricatorMailTestAdapter.php | 4 +-- .../constants/MetaMTAReceivedMailStatus.php | 2 +- .../PhabricatorMetaMTAMailViewController.php | 2 +- .../metamta/engine/PhabricatorMailEmailEngine.php | 26 ++++++++++------- ...habricatorMailManagementListInboundWorkflow.php | 2 +- ...abricatorMailManagementListOutboundWorkflow.php | 2 +- .../parser/PhabricatorMetaMTAEmailBodyParser.php | 1 + .../storage/PhabricatorMetaMTAReceivedMail.php | 33 +++++++++++----------- .../__tests__/PhabricatorMetaMTAMailTestCase.php | 4 +-- .../metamta/util/PhabricatorMailUtil.php | 5 ++-- .../settings/setting/PhabricatorEditorSetting.php | 2 +- .../settings/setting/PhabricatorSelectSetting.php | 5 +++- .../mysql/AphrontBaseMySQLDatabaseConnection.php | 1 + 18 files changed, 59 insertions(+), 49 deletions(-) diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php index c903fbb37f..262aa12d7b 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php +++ b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php @@ -98,7 +98,7 @@ final class HarbormasterBuildPlanQuery $this->statuses); } - if (strlen($this->datasourceQuery)) { + if (!phutil_nonempty_string($this->datasourceQuery)) { $where[] = qsprintf( $conn, 'plan.name LIKE %>', diff --git a/src/applications/harbormaster/step/HarbormasterUploadArtifactBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterUploadArtifactBuildStepImplementation.php index f8bdb7fdfd..0779ccb186 100644 --- a/src/applications/harbormaster/step/HarbormasterUploadArtifactBuildStepImplementation.php +++ b/src/applications/harbormaster/step/HarbormasterUploadArtifactBuildStepImplementation.php @@ -8,7 +8,7 @@ final class HarbormasterUploadArtifactBuildStepImplementation } public function getGenericDescription() { - return pht('Upload a file from a host to Phabricator.'); + return pht('Upload a file.'); } public function getBuildStepGroupKey() { diff --git a/src/applications/legalpad/editor/LegalpadDocumentEditEngine.php b/src/applications/legalpad/editor/LegalpadDocumentEditEngine.php index 814647b82a..fb3f54275a 100644 --- a/src/applications/legalpad/editor/LegalpadDocumentEditEngine.php +++ b/src/applications/legalpad/editor/LegalpadDocumentEditEngine.php @@ -131,7 +131,7 @@ final class LegalpadDocumentEditEngine ->setKey('requireSignature') ->setOptions( pht('No Signature Required'), - pht('Signature Required to use Phabricator')) + pht('Signature Required to Log In')) ->setAsCheckbox(true) ->setTransactionType( LegalpadDocumentRequireSignatureTransaction::TRANSACTIONTYPE) diff --git a/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php b/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php index 60a41a26ca..9bb3987415 100644 --- a/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php +++ b/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php @@ -218,7 +218,7 @@ The keys you can provide in a specification are: Statuses will appear in the UI in the order specified. Note the status marked `special` as `duplicate` is not settable directly and will not appear in UI -elements, and that any status marked `silly` does not appear if Phabricator +elements, and that any status marked `silly` does not appear if the software is configured with `phabricator.serious-business` set to true. Examining the default configuration and examples below will probably be helpful diff --git a/src/applications/meta/controller/PhabricatorApplicationUninstallController.php b/src/applications/meta/controller/PhabricatorApplicationUninstallController.php index 09f3e92ee5..e89976c42c 100644 --- a/src/applications/meta/controller/PhabricatorApplicationUninstallController.php +++ b/src/applications/meta/controller/PhabricatorApplicationUninstallController.php @@ -38,7 +38,7 @@ final class PhabricatorApplicationUninstallController ->appendChild( pht( 'To manage prototypes, enable them by setting %s in your '. - 'Phabricator configuration.', + 'configuration.', phutil_tag('tt', array(), 'phabricator.show-prototypes'))); return id(new AphrontDialogResponse())->setDialog($dialog); } @@ -98,9 +98,9 @@ final class PhabricatorApplicationUninstallController ->appendParagraph( pht( 'This is very unusual and will leave you without any '. - 'content on the Phabricator home page. You should only '. - 'do this if you are certain you know what you are doing.')) - ->addSubmitButton(pht('Completely Break Phabricator')); + 'content on the home page. You should only do this if you '. + 'are certain you know what you are doing.')) + ->addSubmitButton(pht('Completely Break Everything')); } else { $dialog ->appendParagraph( @@ -114,8 +114,7 @@ final class PhabricatorApplicationUninstallController ->setTitle(pht('Information')) ->appendChild( pht( - 'This application cannot be uninstalled, '. - 'because it is required for Phabricator to work.')); + 'This application is required and cannot be uninstalled.')); } } return id(new AphrontDialogResponse())->setDialog($dialog); diff --git a/src/applications/metamta/adapter/PhabricatorMailTestAdapter.php b/src/applications/metamta/adapter/PhabricatorMailTestAdapter.php index a6258a8874..311dd78b99 100644 --- a/src/applications/metamta/adapter/PhabricatorMailTestAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailTestAdapter.php @@ -126,12 +126,12 @@ final class PhabricatorMailTestAdapter $guts['headers'] = $header_list; $text_body = $message->getTextBody(); - if (strlen($text_body)) { + if (phutil_nonempty_string($text_body)) { $guts['body'] = $text_body; } $html_body = $message->getHTMLBody(); - if (strlen($html_body)) { + if (phutil_nonempty_string($html_body)) { $guts['html-body'] = $html_body; } diff --git a/src/applications/metamta/constants/MetaMTAReceivedMailStatus.php b/src/applications/metamta/constants/MetaMTAReceivedMailStatus.php index faacdc2cfc..871d47f97f 100644 --- a/src/applications/metamta/constants/MetaMTAReceivedMailStatus.php +++ b/src/applications/metamta/constants/MetaMTAReceivedMailStatus.php @@ -21,7 +21,7 @@ final class MetaMTAReceivedMailStatus public static function getHumanReadableName($status) { $map = array( self::STATUS_DUPLICATE => pht('Duplicate Message'), - self::STATUS_FROM_PHABRICATOR => pht('Phabricator Mail'), + self::STATUS_FROM_PHABRICATOR => pht('Mail From Self'), self::STATUS_NO_RECEIVERS => pht('No Receivers'), self::STATUS_UNKNOWN_SENDER => pht('Unknown Sender'), self::STATUS_DISABLED_SENDER => pht('Disabled Sender'), diff --git a/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php b/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php index d7d31ba254..8029294581 100644 --- a/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php +++ b/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php @@ -428,7 +428,7 @@ final class PhabricatorMetaMTAMailViewController if ($actor_phid) { $actor_str = $viewer->renderHandle($actor_phid); } else { - $actor_str = pht('Generated by Phabricator'); + $actor_str = pht('Generated by Server'); } $properties->addProperty(pht('Actor'), $actor_str); diff --git a/src/applications/metamta/engine/PhabricatorMailEmailEngine.php b/src/applications/metamta/engine/PhabricatorMailEmailEngine.php index ef7b92a7d3..6c9cf1b356 100644 --- a/src/applications/metamta/engine/PhabricatorMailEmailEngine.php +++ b/src/applications/metamta/engine/PhabricatorMailEmailEngine.php @@ -119,6 +119,8 @@ final class PhabricatorMailEmailEngine } $body_limit = PhabricatorEnv::getEnvConfig('metamta.email-body-limit'); + + $body = phutil_string_cast($body); if (strlen($body) > $body_limit) { $body = id(new PhutilUTF8StringTruncator()) ->setMaximumBytes($body_limit) @@ -143,7 +145,7 @@ final class PhabricatorMailEmailEngine if ($send_html) { $html_body = $mail->getHTMLBody(); - if (strlen($html_body)) { + if (phutil_nonempty_string($html_body)) { // NOTE: We just drop the entire HTML body if it won't fit. Safely // truncating HTML is hard, and we already have the text body to fall // back to. @@ -166,7 +168,7 @@ final class PhabricatorMailEmailEngine if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { $mail->setMessage( pht( - 'Phabricator is running in silent mode. See `%s` '. + 'This software is running in silent mode. See `%s` '. 'in the configuration to change this setting.', 'phabricator.silent')); @@ -226,7 +228,7 @@ final class PhabricatorMailEmailEngine $mail = $this->getMail(); $reply_raw = $mail->getReplyTo(); - if (!strlen($reply_raw)) { + if (!phutil_nonempty_string($reply_raw)) { return null; } @@ -241,7 +243,7 @@ final class PhabricatorMailEmailEngine // If we don't have a display name, fill in a default. if (!strlen($reply_address->getDisplayName())) { - $reply_address->setDisplayName(pht('Phabricator')); + $reply_address->setDisplayName(PlatformSymbols::getPlatformServerName()); } return $reply_address; @@ -301,7 +303,11 @@ final class PhabricatorMailEmailEngine } } - $subject[] = trim($mail->getSubjectPrefix()); + $subject_prefix = $mail->getSubjectPrefix(); + $subject_prefix = phutil_string_cast($subject_prefix); + $subject_prefix = trim($subject_prefix); + + $subject[] = $subject_prefix; // If mail content must be encrypted, we replace the subject with // a generic one. @@ -313,7 +319,7 @@ final class PhabricatorMailEmailEngine $subject[] = $encrypt_subject; } else { $vary_prefix = $mail->getVarySubjectPrefix(); - if (strlen($vary_prefix)) { + if (phutil_nonempty_string($vary_prefix)) { if ($this->shouldVarySubject()) { $subject[] = $vary_prefix; } @@ -323,7 +329,7 @@ final class PhabricatorMailEmailEngine } foreach ($subject as $key => $part) { - if (!strlen($part)) { + if (!phutil_nonempty_string($part)) { unset($subject[$key]); } } @@ -403,7 +409,7 @@ final class PhabricatorMailEmailEngine $headers = array(); $thread_id = $mail->getThreadID(); - if (!strlen($thread_id)) { + if (!phutil_nonempty_string($thread_id)) { return $headers; } @@ -508,8 +514,8 @@ final class PhabricatorMailEmailEngine $address = new PhutilEmailAddress($raw_address); - if (!strlen($address->getDisplayName())) { - $address->setDisplayName(pht('Phabricator')); + if (!phutil_nonempty_string($address->getDisplayName())) { + $address->setDisplayName(PlatformSymbols::getPlatformServerName()); } return $address; diff --git a/src/applications/metamta/management/PhabricatorMailManagementListInboundWorkflow.php b/src/applications/metamta/management/PhabricatorMailManagementListInboundWorkflow.php index 02ed82a6b0..c19923026d 100644 --- a/src/applications/metamta/management/PhabricatorMailManagementListInboundWorkflow.php +++ b/src/applications/metamta/management/PhabricatorMailManagementListInboundWorkflow.php @@ -6,7 +6,7 @@ final class PhabricatorMailManagementListInboundWorkflow protected function didConstruct() { $this ->setName('list-inbound') - ->setSynopsis(pht('List inbound messages received by Phabricator.')) + ->setSynopsis(pht('List inbound messages.')) ->setExamples( '**list-inbound**') ->setArguments( diff --git a/src/applications/metamta/management/PhabricatorMailManagementListOutboundWorkflow.php b/src/applications/metamta/management/PhabricatorMailManagementListOutboundWorkflow.php index 30939dd436..77c363a45b 100644 --- a/src/applications/metamta/management/PhabricatorMailManagementListOutboundWorkflow.php +++ b/src/applications/metamta/management/PhabricatorMailManagementListOutboundWorkflow.php @@ -6,7 +6,7 @@ final class PhabricatorMailManagementListOutboundWorkflow protected function didConstruct() { $this ->setName('list-outbound') - ->setSynopsis(pht('List outbound messages sent by Phabricator.')) + ->setSynopsis(pht('List outbound messages.')) ->setExamples('**list-outbound**') ->setArguments( array( diff --git a/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php b/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php index 9b266a3ae7..f20e626573 100644 --- a/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php +++ b/src/applications/metamta/parser/PhabricatorMetaMTAEmailBodyParser.php @@ -81,6 +81,7 @@ final class PhabricatorMetaMTAEmailBodyParser extends Phobject { } private function stripQuotedText($body) { + $body = phutil_string_cast($body); // Look for "On , wrote:". This may be split across multiple // lines. We need to be careful not to remove all of a message like this: diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php index c620bea30a..d3289bbc69 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php @@ -263,19 +263,16 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { MetaMTAReceivedMailStatus::STATUS_UNKNOWN_SENDER, pht( 'This email was sent from an email address ("%s") that is not '. - 'associated with a Phabricator account. To interact with '. - 'Phabricator via email, add this address to your account.', + 'associated with a registered user account. To interact via '. + 'email, add this address to your account.', (string)$this->newFromAddress())); } else { throw new PhabricatorMetaMTAReceivedMailProcessingException( MetaMTAReceivedMailStatus::STATUS_NO_RECEIVERS, pht( - 'Phabricator can not process this mail because no application '. + 'This mail can not be processed because no application '. 'knows how to handle it. Check that the address you sent it to '. - 'is correct.'. - "\n\n". - '(No concrete, enabled subclass of PhabricatorMailReceiver can '. - 'accept this mail.)')); + 'is correct.')); } } } catch (PhabricatorMetaMTAReceivedMailProcessingException $ex) { @@ -348,9 +345,13 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { private function getRawEmailAddresses($addresses) { $raw_addresses = array(); - foreach (explode(',', $addresses) as $address) { - $raw_addresses[] = $this->getRawEmailAddress($address); + + if (phutil_nonempty_string($addresses)) { + foreach (explode(',', $addresses) as $address) { + $raw_addresses[] = $this->getRawEmailAddress($address); + } } + return array_filter($raw_addresses); } @@ -436,7 +437,7 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { $status_code, pht( 'Your message does not contain any body text or attachments, so '. - 'Phabricator can not do anything useful with it. Make sure comment '. + 'this server can not do anything useful with it. Make sure comment '. 'text appears at the top of your message: quoted replies, inline '. 'text, and signatures are discarded and ignored.')); } @@ -484,7 +485,7 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { $headers = implode("\n", $headers); $body = pht(<<getRawTextBody(), $headers); @@ -563,21 +565,20 @@ EOBODY if ($sender->getIsDisabled()) { $failure_reason = pht( 'Your account ("%s") is disabled, so you can not interact with '. - 'Phabricator over email.', + 'over email.', $sender->getUsername()); } else if ($sender->getIsStandardUser()) { if (!$sender->getIsApproved()) { $failure_reason = pht( 'Your account ("%s") has not been approved yet. You can not '. - 'interact with Phabricator over email until your account is '. - 'approved.', + 'interact over email until your account is approved.', $sender->getUsername()); } else if (PhabricatorUserEmail::isEmailVerificationRequired() && !$sender->getIsEmailVerified()) { $failure_reason = pht( 'You have not verified the email address for your account ("%s"). '. - 'You must verify your email address before you can interact '. - 'with Phabricator over email.', + 'You must verify your email address before you can interact over '. + 'email.', $sender->getUsername()); } } diff --git a/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php b/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php index 7462aaf558..e66dd8c61b 100644 --- a/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php +++ b/src/applications/metamta/storage/__tests__/PhabricatorMetaMTAMailTestCase.php @@ -395,7 +395,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { // We expect the HTML body was dropped completely after the text body was // truncated. $this->assertTrue( - !strlen($html_body), + !phutil_nonempty_string($html_body), pht('HTML Body Removed')); @@ -416,7 +416,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase { $html_body = $mailer->getHTMLBody(); $this->assertEqual($string_1kb, $text_body); - $this->assertTrue(!strlen($html_body)); + $this->assertTrue(!phutil_nonempty_string($html_body)); } } diff --git a/src/applications/metamta/util/PhabricatorMailUtil.php b/src/applications/metamta/util/PhabricatorMailUtil.php index a5fbc7179e..270e9786f3 100644 --- a/src/applications/metamta/util/PhabricatorMailUtil.php +++ b/src/applications/metamta/util/PhabricatorMailUtil.php @@ -21,11 +21,10 @@ final class PhabricatorMailUtil // If a mailbox prefix is configured and present, strip it off. $prefix_key = 'metamta.single-reply-handler-prefix'; $prefix = PhabricatorEnv::getEnvConfig($prefix_key); - $len = strlen($prefix); - if ($len) { + if (phutil_nonempty_string($prefix)) { $prefix = $prefix.'+'; - $len = $len + 1; + $len = strlen($prefix); if (!strncasecmp($raw_address, $prefix, $len)) { $raw_address = substr($raw_address, $len); diff --git a/src/applications/settings/setting/PhabricatorEditorSetting.php b/src/applications/settings/setting/PhabricatorEditorSetting.php index a0f1b43c95..1262a17e4d 100644 --- a/src/applications/settings/setting/PhabricatorEditorSetting.php +++ b/src/applications/settings/setting/PhabricatorEditorSetting.php @@ -42,7 +42,7 @@ final class PhabricatorEditorSetting } public function validateTransactionValue($value) { - if (!strlen($value)) { + if (!phutil_nonempty_string($value)) { return; } diff --git a/src/applications/settings/setting/PhabricatorSelectSetting.php b/src/applications/settings/setting/PhabricatorSelectSetting.php index bccf450454..fb3cb2135f 100644 --- a/src/applications/settings/setting/PhabricatorSelectSetting.php +++ b/src/applications/settings/setting/PhabricatorSelectSetting.php @@ -47,6 +47,7 @@ abstract class PhabricatorSelectSetting } final public function validateTransactionValue($value) { + $value = phutil_string_cast($value); if (!strlen($value)) { return; } @@ -66,11 +67,13 @@ abstract class PhabricatorSelectSetting } public function getTransactionNewValue($value) { + $value = phutil_string_cast($value); + if (!strlen($value)) { return null; } - return (string)$value; + return $value; } } diff --git a/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php b/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php index db52eebe8e..6ff9b3ba90 100644 --- a/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php +++ b/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php @@ -77,6 +77,7 @@ abstract class AphrontBaseMySQLDatabaseConnection } public function escapeStringForLikeClause($value) { + $value = phutil_string_cast($value); $value = addcslashes($value, '\%_'); $value = $this->escapeUTF8String($value); return $value; -- 2.11.4.GIT