Skip to content

Commit 32d2325

Browse files
author
epriestley
committedFeb 26, 2013
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
1 parent 51a1b76 commit 32d2325

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
 

‎scripts/sql/manage_storage.php

+2
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@
7575
} else {
7676
// Put this in a PhutilOpaqueEnvelope.
7777
$password = new PhutilOpaqueEnvelope($args->getArg('password'));
78+
PhabricatorEnv::overrideConfig('mysql.pass', $args->getArg('password'));
7879
}
7980

8081
$api = new PhabricatorStorageManagementAPI();
8182
$api->setUser($args->getArg('user'));
83+
PhabricatorEnv::overrideConfig('mysql.user', $args->getArg('user'));
8284
$api->setHost($default_host);
8385
$api->setPassword($password);
8486
$api->setNamespace($args->getArg('namespace'));

‎src/infrastructure/env/PhabricatorEnv.php

+10
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ final class PhabricatorEnv {
5252

5353
private static $sourceStack;
5454
private static $repairSource;
55+
private static $overrideSource;
5556
private static $requestBaseURI;
5657

5758
/**
@@ -161,6 +162,15 @@ public static function repairConfig($key, $value) {
161162
self::$repairSource->setKeys(array($key => $value));
162163
}
163164

165+
public static function overrideConfig($key, $value) {
166+
if (!self::$overrideSource) {
167+
self::$overrideSource = id(new PhabricatorConfigDictionarySource(array()))
168+
->setName(pht("Overridden Config"));
169+
self::$sourceStack->pushSource(self::$overrideSource);
170+
}
171+
self::$overrideSource->setKeys(array($key => $value));
172+
}
173+
164174
public static function getUnrepairedEnvConfig($key, $default = null) {
165175
foreach (self::$sourceStack->getStack() as $source) {
166176
if ($source === self::$repairSource) {

0 commit comments

Comments
 (0)
Failed to load comments.