1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

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
This commit is contained in:
epriestley 2022-04-25 11:36:02 -07:00
parent ad880491e8
commit b3557796fe
18 changed files with 59 additions and 49 deletions

View file

@ -98,7 +98,7 @@ final class HarbormasterBuildPlanQuery
$this->statuses); $this->statuses);
} }
if (strlen($this->datasourceQuery)) { if (!phutil_nonempty_string($this->datasourceQuery)) {
$where[] = qsprintf( $where[] = qsprintf(
$conn, $conn,
'plan.name LIKE %>', 'plan.name LIKE %>',

View file

@ -8,7 +8,7 @@ final class HarbormasterUploadArtifactBuildStepImplementation
} }
public function getGenericDescription() { public function getGenericDescription() {
return pht('Upload a file from a host to Phabricator.'); return pht('Upload a file.');
} }
public function getBuildStepGroupKey() { public function getBuildStepGroupKey() {

View file

@ -131,7 +131,7 @@ final class LegalpadDocumentEditEngine
->setKey('requireSignature') ->setKey('requireSignature')
->setOptions( ->setOptions(
pht('No Signature Required'), pht('No Signature Required'),
pht('Signature Required to use Phabricator')) pht('Signature Required to Log In'))
->setAsCheckbox(true) ->setAsCheckbox(true)
->setTransactionType( ->setTransactionType(
LegalpadDocumentRequireSignatureTransaction::TRANSACTIONTYPE) LegalpadDocumentRequireSignatureTransaction::TRANSACTIONTYPE)

View file

@ -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 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 `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. is configured with `phabricator.serious-business` set to true.
Examining the default configuration and examples below will probably be helpful Examining the default configuration and examples below will probably be helpful

View file

@ -38,7 +38,7 @@ final class PhabricatorApplicationUninstallController
->appendChild( ->appendChild(
pht( pht(
'To manage prototypes, enable them by setting %s in your '. 'To manage prototypes, enable them by setting %s in your '.
'Phabricator configuration.', 'configuration.',
phutil_tag('tt', array(), 'phabricator.show-prototypes'))); phutil_tag('tt', array(), 'phabricator.show-prototypes')));
return id(new AphrontDialogResponse())->setDialog($dialog); return id(new AphrontDialogResponse())->setDialog($dialog);
} }
@ -98,9 +98,9 @@ final class PhabricatorApplicationUninstallController
->appendParagraph( ->appendParagraph(
pht( pht(
'This is very unusual and will leave you without any '. 'This is very unusual and will leave you without any '.
'content on the Phabricator home page. You should only '. 'content on the home page. You should only do this if you '.
'do this if you are certain you know what you are doing.')) 'are certain you know what you are doing.'))
->addSubmitButton(pht('Completely Break Phabricator')); ->addSubmitButton(pht('Completely Break Everything'));
} else { } else {
$dialog $dialog
->appendParagraph( ->appendParagraph(
@ -114,8 +114,7 @@ final class PhabricatorApplicationUninstallController
->setTitle(pht('Information')) ->setTitle(pht('Information'))
->appendChild( ->appendChild(
pht( pht(
'This application cannot be uninstalled, '. 'This application is required and cannot be uninstalled.'));
'because it is required for Phabricator to work.'));
} }
} }
return id(new AphrontDialogResponse())->setDialog($dialog); return id(new AphrontDialogResponse())->setDialog($dialog);

View file

@ -126,12 +126,12 @@ final class PhabricatorMailTestAdapter
$guts['headers'] = $header_list; $guts['headers'] = $header_list;
$text_body = $message->getTextBody(); $text_body = $message->getTextBody();
if (strlen($text_body)) { if (phutil_nonempty_string($text_body)) {
$guts['body'] = $text_body; $guts['body'] = $text_body;
} }
$html_body = $message->getHTMLBody(); $html_body = $message->getHTMLBody();
if (strlen($html_body)) { if (phutil_nonempty_string($html_body)) {
$guts['html-body'] = $html_body; $guts['html-body'] = $html_body;
} }

View file

@ -21,7 +21,7 @@ final class MetaMTAReceivedMailStatus
public static function getHumanReadableName($status) { public static function getHumanReadableName($status) {
$map = array( $map = array(
self::STATUS_DUPLICATE => pht('Duplicate Message'), 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_NO_RECEIVERS => pht('No Receivers'),
self::STATUS_UNKNOWN_SENDER => pht('Unknown Sender'), self::STATUS_UNKNOWN_SENDER => pht('Unknown Sender'),
self::STATUS_DISABLED_SENDER => pht('Disabled Sender'), self::STATUS_DISABLED_SENDER => pht('Disabled Sender'),

View file

@ -428,7 +428,7 @@ final class PhabricatorMetaMTAMailViewController
if ($actor_phid) { if ($actor_phid) {
$actor_str = $viewer->renderHandle($actor_phid); $actor_str = $viewer->renderHandle($actor_phid);
} else { } else {
$actor_str = pht('Generated by Phabricator'); $actor_str = pht('Generated by Server');
} }
$properties->addProperty(pht('Actor'), $actor_str); $properties->addProperty(pht('Actor'), $actor_str);

View file

@ -119,6 +119,8 @@ final class PhabricatorMailEmailEngine
} }
$body_limit = PhabricatorEnv::getEnvConfig('metamta.email-body-limit'); $body_limit = PhabricatorEnv::getEnvConfig('metamta.email-body-limit');
$body = phutil_string_cast($body);
if (strlen($body) > $body_limit) { if (strlen($body) > $body_limit) {
$body = id(new PhutilUTF8StringTruncator()) $body = id(new PhutilUTF8StringTruncator())
->setMaximumBytes($body_limit) ->setMaximumBytes($body_limit)
@ -143,7 +145,7 @@ final class PhabricatorMailEmailEngine
if ($send_html) { if ($send_html) {
$html_body = $mail->getHTMLBody(); $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 // 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 // truncating HTML is hard, and we already have the text body to fall
// back to. // back to.
@ -166,7 +168,7 @@ final class PhabricatorMailEmailEngine
if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { if (PhabricatorEnv::getEnvConfig('phabricator.silent')) {
$mail->setMessage( $mail->setMessage(
pht( 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.', 'in the configuration to change this setting.',
'phabricator.silent')); 'phabricator.silent'));
@ -226,7 +228,7 @@ final class PhabricatorMailEmailEngine
$mail = $this->getMail(); $mail = $this->getMail();
$reply_raw = $mail->getReplyTo(); $reply_raw = $mail->getReplyTo();
if (!strlen($reply_raw)) { if (!phutil_nonempty_string($reply_raw)) {
return null; return null;
} }
@ -241,7 +243,7 @@ final class PhabricatorMailEmailEngine
// If we don't have a display name, fill in a default. // If we don't have a display name, fill in a default.
if (!strlen($reply_address->getDisplayName())) { if (!strlen($reply_address->getDisplayName())) {
$reply_address->setDisplayName(pht('Phabricator')); $reply_address->setDisplayName(PlatformSymbols::getPlatformServerName());
} }
return $reply_address; 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 // If mail content must be encrypted, we replace the subject with
// a generic one. // a generic one.
@ -313,7 +319,7 @@ final class PhabricatorMailEmailEngine
$subject[] = $encrypt_subject; $subject[] = $encrypt_subject;
} else { } else {
$vary_prefix = $mail->getVarySubjectPrefix(); $vary_prefix = $mail->getVarySubjectPrefix();
if (strlen($vary_prefix)) { if (phutil_nonempty_string($vary_prefix)) {
if ($this->shouldVarySubject()) { if ($this->shouldVarySubject()) {
$subject[] = $vary_prefix; $subject[] = $vary_prefix;
} }
@ -323,7 +329,7 @@ final class PhabricatorMailEmailEngine
} }
foreach ($subject as $key => $part) { foreach ($subject as $key => $part) {
if (!strlen($part)) { if (!phutil_nonempty_string($part)) {
unset($subject[$key]); unset($subject[$key]);
} }
} }
@ -403,7 +409,7 @@ final class PhabricatorMailEmailEngine
$headers = array(); $headers = array();
$thread_id = $mail->getThreadID(); $thread_id = $mail->getThreadID();
if (!strlen($thread_id)) { if (!phutil_nonempty_string($thread_id)) {
return $headers; return $headers;
} }
@ -508,8 +514,8 @@ final class PhabricatorMailEmailEngine
$address = new PhutilEmailAddress($raw_address); $address = new PhutilEmailAddress($raw_address);
if (!strlen($address->getDisplayName())) { if (!phutil_nonempty_string($address->getDisplayName())) {
$address->setDisplayName(pht('Phabricator')); $address->setDisplayName(PlatformSymbols::getPlatformServerName());
} }
return $address; return $address;

View file

@ -6,7 +6,7 @@ final class PhabricatorMailManagementListInboundWorkflow
protected function didConstruct() { protected function didConstruct() {
$this $this
->setName('list-inbound') ->setName('list-inbound')
->setSynopsis(pht('List inbound messages received by Phabricator.')) ->setSynopsis(pht('List inbound messages.'))
->setExamples( ->setExamples(
'**list-inbound**') '**list-inbound**')
->setArguments( ->setArguments(

View file

@ -6,7 +6,7 @@ final class PhabricatorMailManagementListOutboundWorkflow
protected function didConstruct() { protected function didConstruct() {
$this $this
->setName('list-outbound') ->setName('list-outbound')
->setSynopsis(pht('List outbound messages sent by Phabricator.')) ->setSynopsis(pht('List outbound messages.'))
->setExamples('**list-outbound**') ->setExamples('**list-outbound**')
->setArguments( ->setArguments(
array( array(

View file

@ -81,6 +81,7 @@ final class PhabricatorMetaMTAEmailBodyParser extends Phobject {
} }
private function stripQuotedText($body) { private function stripQuotedText($body) {
$body = phutil_string_cast($body);
// Look for "On <date>, <user> wrote:". This may be split across multiple // Look for "On <date>, <user> wrote:". This may be split across multiple
// lines. We need to be careful not to remove all of a message like this: // lines. We need to be careful not to remove all of a message like this:

View file

@ -263,19 +263,16 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
MetaMTAReceivedMailStatus::STATUS_UNKNOWN_SENDER, MetaMTAReceivedMailStatus::STATUS_UNKNOWN_SENDER,
pht( pht(
'This email was sent from an email address ("%s") that is not '. 'This email was sent from an email address ("%s") that is not '.
'associated with a Phabricator account. To interact with '. 'associated with a registered user account. To interact via '.
'Phabricator via email, add this address to your account.', 'email, add this address to your account.',
(string)$this->newFromAddress())); (string)$this->newFromAddress()));
} else { } else {
throw new PhabricatorMetaMTAReceivedMailProcessingException( throw new PhabricatorMetaMTAReceivedMailProcessingException(
MetaMTAReceivedMailStatus::STATUS_NO_RECEIVERS, MetaMTAReceivedMailStatus::STATUS_NO_RECEIVERS,
pht( 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 '. 'knows how to handle it. Check that the address you sent it to '.
'is correct.'. 'is correct.'));
"\n\n".
'(No concrete, enabled subclass of PhabricatorMailReceiver can '.
'accept this mail.)'));
} }
} }
} catch (PhabricatorMetaMTAReceivedMailProcessingException $ex) { } catch (PhabricatorMetaMTAReceivedMailProcessingException $ex) {
@ -348,9 +345,13 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
private function getRawEmailAddresses($addresses) { private function getRawEmailAddresses($addresses) {
$raw_addresses = array(); $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); return array_filter($raw_addresses);
} }
@ -436,7 +437,7 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
$status_code, $status_code,
pht( pht(
'Your message does not contain any body text or attachments, so '. '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 appears at the top of your message: quoted replies, inline '.
'text, and signatures are discarded and ignored.')); 'text, and signatures are discarded and ignored.'));
} }
@ -484,7 +485,7 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
$headers = implode("\n", $headers); $headers = implode("\n", $headers);
$body = pht(<<<EOBODY $body = pht(<<<EOBODY
Your email to Phabricator was not processed, because an error occurred while Your email to %s was not processed, because an error occurred while
trying to handle it: trying to handle it:
%s %s
@ -499,6 +500,7 @@ trying to handle it:
EOBODY EOBODY
, ,
PlatformSymbols::getPlatformServerName(),
wordwrap($description, 78), wordwrap($description, 78),
$this->getRawTextBody(), $this->getRawTextBody(),
$headers); $headers);
@ -563,21 +565,20 @@ EOBODY
if ($sender->getIsDisabled()) { if ($sender->getIsDisabled()) {
$failure_reason = pht( $failure_reason = pht(
'Your account ("%s") is disabled, so you can not interact with '. 'Your account ("%s") is disabled, so you can not interact with '.
'Phabricator over email.', 'over email.',
$sender->getUsername()); $sender->getUsername());
} else if ($sender->getIsStandardUser()) { } else if ($sender->getIsStandardUser()) {
if (!$sender->getIsApproved()) { if (!$sender->getIsApproved()) {
$failure_reason = pht( $failure_reason = pht(
'Your account ("%s") has not been approved yet. You can not '. 'Your account ("%s") has not been approved yet. You can not '.
'interact with Phabricator over email until your account is '. 'interact over email until your account is approved.',
'approved.',
$sender->getUsername()); $sender->getUsername());
} else if (PhabricatorUserEmail::isEmailVerificationRequired() && } else if (PhabricatorUserEmail::isEmailVerificationRequired() &&
!$sender->getIsEmailVerified()) { !$sender->getIsEmailVerified()) {
$failure_reason = pht( $failure_reason = pht(
'You have not verified the email address for your account ("%s"). '. 'You have not verified the email address for your account ("%s"). '.
'You must verify your email address before you can interact '. 'You must verify your email address before you can interact over '.
'with Phabricator over email.', 'email.',
$sender->getUsername()); $sender->getUsername());
} }
} }

View file

@ -395,7 +395,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
// We expect the HTML body was dropped completely after the text body was // We expect the HTML body was dropped completely after the text body was
// truncated. // truncated.
$this->assertTrue( $this->assertTrue(
!strlen($html_body), !phutil_nonempty_string($html_body),
pht('HTML Body Removed')); pht('HTML Body Removed'));
@ -416,7 +416,7 @@ final class PhabricatorMetaMTAMailTestCase extends PhabricatorTestCase {
$html_body = $mailer->getHTMLBody(); $html_body = $mailer->getHTMLBody();
$this->assertEqual($string_1kb, $text_body); $this->assertEqual($string_1kb, $text_body);
$this->assertTrue(!strlen($html_body)); $this->assertTrue(!phutil_nonempty_string($html_body));
} }
} }

View file

@ -21,11 +21,10 @@ final class PhabricatorMailUtil
// If a mailbox prefix is configured and present, strip it off. // If a mailbox prefix is configured and present, strip it off.
$prefix_key = 'metamta.single-reply-handler-prefix'; $prefix_key = 'metamta.single-reply-handler-prefix';
$prefix = PhabricatorEnv::getEnvConfig($prefix_key); $prefix = PhabricatorEnv::getEnvConfig($prefix_key);
$len = strlen($prefix);
if ($len) { if (phutil_nonempty_string($prefix)) {
$prefix = $prefix.'+'; $prefix = $prefix.'+';
$len = $len + 1; $len = strlen($prefix);
if (!strncasecmp($raw_address, $prefix, $len)) { if (!strncasecmp($raw_address, $prefix, $len)) {
$raw_address = substr($raw_address, $len); $raw_address = substr($raw_address, $len);

View file

@ -42,7 +42,7 @@ final class PhabricatorEditorSetting
} }
public function validateTransactionValue($value) { public function validateTransactionValue($value) {
if (!strlen($value)) { if (!phutil_nonempty_string($value)) {
return; return;
} }

View file

@ -47,6 +47,7 @@ abstract class PhabricatorSelectSetting
} }
final public function validateTransactionValue($value) { final public function validateTransactionValue($value) {
$value = phutil_string_cast($value);
if (!strlen($value)) { if (!strlen($value)) {
return; return;
} }
@ -66,11 +67,13 @@ abstract class PhabricatorSelectSetting
} }
public function getTransactionNewValue($value) { public function getTransactionNewValue($value) {
$value = phutil_string_cast($value);
if (!strlen($value)) { if (!strlen($value)) {
return null; return null;
} }
return (string)$value; return $value;
} }
} }

View file

@ -77,6 +77,7 @@ abstract class AphrontBaseMySQLDatabaseConnection
} }
public function escapeStringForLikeClause($value) { public function escapeStringForLikeClause($value) {
$value = phutil_string_cast($value);
$value = addcslashes($value, '\%_'); $value = addcslashes($value, '\%_');
$value = $this->escapeUTF8String($value); $value = $this->escapeUTF8String($value);
return $value; return $value;