@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

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

+12 -11
+12 -7
src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php
··· 40 40 $query->withIDs($ids); 41 41 } 42 42 $daemons = $query->execute(); 43 + $daemons = mpull($daemons, null, 'getID'); 43 44 44 - if (!$daemons) { 45 - if ($ids) { 46 - throw new PhutilArgumentUsageException( 47 - pht('No daemon(s) with id(s) "%s" exist!', implode(', ', $ids))); 48 - } else { 49 - throw new PhutilArgumentUsageException( 50 - pht('No daemons are running.')); 45 + if ($ids) { 46 + foreach ($ids as $id) { 47 + if (!isset($daemons[$id])) { 48 + throw new PhutilArgumentUsageException( 49 + pht( 50 + 'No log record exists for a daemon with ID "%s".', 51 + $id)); 52 + } 51 53 } 54 + } else if (!$daemons) { 55 + throw new PhutilArgumentUsageException( 56 + pht('No log records exist for any daemons.')); 52 57 } 53 58 54 59 $console = PhutilConsole::getConsole();
-4
src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
··· 9 9 10 10 protected function getTranslations() { 11 11 return array( 12 - 'No daemon(s) with id(s) "%s" exist!' => array( 13 - 'No daemon with id %s exists!', 14 - 'No daemons with ids %s exist!', 15 - ), 16 12 'These %d configuration value(s) are related:' => array( 17 13 'This configuration value is related:', 18 14 'These configuration values are related:',