mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
Use --user
and --password
from bin/storage in PHP migrations
Summary: Fixes T2059. Ref T2517. Currently, you can run `bin/storage upgrade` with `--user` and `--password` arguments. However, these clownishly apply only to `.sql` patches -- the `.php` migrations still use the default user and password. This is dumb. Stop doing it. Respect `--user` and `--password` for PHP patches. (I implemented "override", which is very similar to "repair", but kept them separate since I think they're semantically distinct enough to differentiate.) Test Plan: Ran `./bin/storage upgrade --user x --pass y --apply phabricator:20130219.commitsummarymig.php`. Verified the correct user and password were used both for the initial connect and patch application. Reviewers: chad, vrana Reviewed By: chad CC: aran Maniphest Tasks: T2059, T2517 Differential Revision: https://secure.phabricator.com/D5115
This commit is contained in:
parent
51a1b76899
commit
32d23254c9
2 changed files with 12 additions and 0 deletions
|
@ -75,10 +75,12 @@ if ($args->getArg('password') === null) {
|
|||
} else {
|
||||
// Put this in a PhutilOpaqueEnvelope.
|
||||
$password = new PhutilOpaqueEnvelope($args->getArg('password'));
|
||||
PhabricatorEnv::overrideConfig('mysql.pass', $args->getArg('password'));
|
||||
}
|
||||
|
||||
$api = new PhabricatorStorageManagementAPI();
|
||||
$api->setUser($args->getArg('user'));
|
||||
PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user'));
|
||||
$api->setHost($default_host);
|
||||
$api->setPassword($password);
|
||||
$api->setNamespace($args->getArg('namespace'));
|
||||
|
|
10
src/infrastructure/env/PhabricatorEnv.php
vendored
10
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -52,6 +52,7 @@ final class PhabricatorEnv {
|
|||
|
||||
private static $sourceStack;
|
||||
private static $repairSource;
|
||||
private static $overrideSource;
|
||||
private static $requestBaseURI;
|
||||
|
||||
/**
|
||||
|
@ -161,6 +162,15 @@ final class PhabricatorEnv {
|
|||
self::$repairSource->setKeys(array($key => $value));
|
||||
}
|
||||
|
||||
public static function overrideConfig($key, $value) {
|
||||
if (!self::$overrideSource) {
|
||||
self::$overrideSource = id(new PhabricatorConfigDictionarySource(array()))
|
||||
->setName(pht("Overridden Config"));
|
||||
self::$sourceStack->pushSource(self::$overrideSource);
|
||||
}
|
||||
self::$overrideSource->setKeys(array($key => $value));
|
||||
}
|
||||
|
||||
public static function getUnrepairedEnvConfig($key, $default = null) {
|
||||
foreach (self::$sourceStack->getStack() as $source) {
|
||||
if ($source === self::$repairSource) {
|
||||
|
|
Loading…
Reference in a new issue