From a7c008708d04cb0e3d010ec7919db0804d3af77c Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 24 Oct 2018 09:38:29 -0700 Subject: [PATCH] Correct a mangled translation string in "bin/phd log --id X" Summary: Ref T13210. See PHI930. This translation is wrong: the parameter is a comma-separated list as a string, but the USEnglish translation provides alternatives. We can't select among alternatives based on a random string (it isn't a plurality value to let us select "chair" vs "chairs", and isn't a gender value to let us select "his profile" vs "her profile") so we get an error. But the string itself is also misleading, since "bin/phd log --id A --id B --id C" will say "none of these are valid" if //any// of them are invalid. Instead, just tell the user explicitly about the first problem. Test Plan: - Ran `bin/phd log --id` with good (got logs) and bad IDs (got sensible error). - Ran `bin/phd log` with any logs (got logs) and (simluated) without any logs (got error). Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13210 Differential Revision: https://secure.phabricator.com/D19755 --- ...PhabricatorDaemonManagementLogWorkflow.php | 19 ++++++++++++------- .../PhabricatorUSEnglishTranslation.php | 4 ---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php index 394b4735a5..8fca624b44 100644 --- a/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php +++ b/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php @@ -40,15 +40,20 @@ final class PhabricatorDaemonManagementLogWorkflow $query->withIDs($ids); } $daemons = $query->execute(); + $daemons = mpull($daemons, null, 'getID'); - if (!$daemons) { - if ($ids) { - throw new PhutilArgumentUsageException( - pht('No daemon(s) with id(s) "%s" exist!', implode(', ', $ids))); - } else { - throw new PhutilArgumentUsageException( - pht('No daemons are running.')); + if ($ids) { + foreach ($ids as $id) { + if (!isset($daemons[$id])) { + throw new PhutilArgumentUsageException( + pht( + 'No log record exists for a daemon with ID "%s".', + $id)); + } } + } else if (!$daemons) { + throw new PhutilArgumentUsageException( + pht('No log records exist for any daemons.')); } $console = PhutilConsole::getConsole(); diff --git a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php index c2241995e7..5169c08ffd 100644 --- a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php +++ b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php @@ -9,10 +9,6 @@ final class PhabricatorUSEnglishTranslation protected function getTranslations() { return array( - 'No daemon(s) with id(s) "%s" exist!' => array( - 'No daemon with id %s exists!', - 'No daemons with ids %s exist!', - ), 'These %d configuration value(s) are related:' => array( 'This configuration value is related:', 'These configuration values are related:',