@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve `bin/storage upgrade` behavior when run out-of-order

Summary:
Fixes T5770. This error occurs if you run `bin/storage upgrade` before you set up MySQL credentials.

This isn't what the setup guide says to do, but it's an easy mistake to make and should be a permitted install path since there's no reason you can't do things in this order.

Specifically, we use a mixture of "standard" (configured) and "administrative" (`--user` and `--password`) credentials, and if the standard ones are bogus bad things happen. We use the standard credentials to make some initialization order stuff easier, and because there's no `--host` flag and adding one would be silly, and because we only need administrative credentials to issue ALTER / CREATE statements.

Test Plan: Ran with bad standard credentials; ran with bad administrative credentials. Ran with good credentials.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5770

Differential Revision: https://secure.phabricator.com/D10199

+52 -4
+52 -4
scripts/sql/manage_storage.php
··· 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