|
70 | 70 | exit(77);
|
71 | 71 | }
|
72 | 72 |
|
| 73 | +// First, test that the Phabricator configuration is set up correctly. After |
| 74 | +// we know this works we'll test any administrative credentials specifically. |
| 75 | + |
| 76 | +$test_api = new PhabricatorStorageManagementAPI(); |
| 77 | +$test_api->setUser($default_user); |
| 78 | +$test_api->setHost($default_host); |
| 79 | +$test_api->setPort($default_port); |
| 80 | +$test_api->setPassword($conf->getPassword()); |
| 81 | +$test_api->setNamespace($args->getArg('namespace')); |
| 82 | + |
| 83 | +try { |
| 84 | + queryfx( |
| 85 | + $test_api->getConn(null), |
| 86 | + 'SELECT 1'); |
| 87 | +} catch (AphrontQueryException $ex) { |
| 88 | + $message = phutil_console_format( |
| 89 | + pht( |
| 90 | + "**MySQL Credentials Not Configured**\n\n". |
| 91 | + "Unable to connect to MySQL using the configured credentials. ". |
| 92 | + "You must configure standard credentials before you can upgrade ". |
| 93 | + "storage. Run these commands to set up credentials:\n". |
| 94 | + "\n". |
| 95 | + " phabricator/ $ ./bin/config set mysql.host __host__\n". |
| 96 | + " phabricator/ $ ./bin/config set mysql.user __username__\n". |
| 97 | + " phabricator/ $ ./bin/config set mysql.pass __password__\n". |
| 98 | + "\n". |
| 99 | + "These standard credentials are separate from any administrative ". |
| 100 | + "credentials provided to this command with __--user__ or ". |
| 101 | + "__--password__, and must be configured correctly before you can ". |
| 102 | + "proceed.\n". |
| 103 | + "\n". |
| 104 | + "**Raw MySQL Error**: %s\n", |
| 105 | + $ex->getMessage())); |
| 106 | + |
| 107 | + echo phutil_console_wrap($message); |
| 108 | + |
| 109 | + exit(1); |
| 110 | +} |
| 111 | + |
| 112 | + |
73 | 113 | if ($args->getArg('password') === null) {
|
74 | 114 | // This is already a PhutilOpaqueEnvelope.
|
75 | 115 | $password = $conf->getPassword();
|
|
92 | 132 | $api->getConn(null),
|
93 | 133 | 'SELECT 1');
|
94 | 134 | } catch (AphrontQueryException $ex) {
|
95 |
| - echo phutil_console_format( |
96 |
| - "**%s**: %s\n", |
97 |
| - 'Unable To Connect', |
98 |
| - $ex->getMessage()); |
| 135 | + $message = phutil_console_format( |
| 136 | + pht( |
| 137 | + "**Bad Administrative Credentials**\n\n". |
| 138 | + "Unable to connnect to MySQL using the administrative credentials ". |
| 139 | + "provided with the __--user__ and __--password__ flags. Check that ". |
| 140 | + "you have entered them correctly.\n". |
| 141 | + "\n". |
| 142 | + "**Raw MySQL Error**: %s\n", |
| 143 | + $ex->getMessage())); |
| 144 | + |
| 145 | + echo phutil_console_wrap($message); |
| 146 | + |
99 | 147 | exit(1);
|
100 | 148 | }
|
101 | 149 |
|
|
0 commit comments