Page MenuHomePhabricator

D11548.id27828.diff
No OneTemporary

D11548.id27828.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2462,6 +2462,7 @@
'PhabricatorStorageManagementDumpWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php',
'PhabricatorStorageManagementProbeWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementProbeWorkflow.php',
'PhabricatorStorageManagementQuickstartWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementQuickstartWorkflow.php',
+ 'PhabricatorStorageManagementShellWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementShellWorkflow.php',
'PhabricatorStorageManagementStatusWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementStatusWorkflow.php',
'PhabricatorStorageManagementUpgradeWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementUpgradeWorkflow.php',
'PhabricatorStorageManagementWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php',
@@ -5753,6 +5754,7 @@
'PhabricatorStorageManagementDumpWorkflow' => 'PhabricatorStorageManagementWorkflow',
'PhabricatorStorageManagementProbeWorkflow' => 'PhabricatorStorageManagementWorkflow',
'PhabricatorStorageManagementQuickstartWorkflow' => 'PhabricatorStorageManagementWorkflow',
+ 'PhabricatorStorageManagementShellWorkflow' => 'PhabricatorStorageManagementWorkflow',
'PhabricatorStorageManagementStatusWorkflow' => 'PhabricatorStorageManagementWorkflow',
'PhabricatorStorageManagementUpgradeWorkflow' => 'PhabricatorStorageManagementWorkflow',
'PhabricatorStorageManagementWorkflow' => 'PhabricatorManagementWorkflow',
diff --git a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
--- a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
+++ b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
@@ -32,7 +32,6 @@
list($host, $port) = $this->getBareHostAndPort($api->getHost());
$flag_password = '';
-
$password = $api->getPassword();
if ($password) {
if (strlen($password->openEnvelope())) {
@@ -54,19 +53,4 @@
$databases);
}
- private function getBareHostAndPort($host) {
- // Split out port information, since the command-line client requires a
- // separate flag for the port.
- $uri = new PhutilURI('mysql://'.$host);
- if ($uri->getPort()) {
- $port = $uri->getPort();
- $bare_hostname = $uri->getDomain();
- } else {
- $port = null;
- $bare_hostname = $host;
- }
-
- return array($bare_hostname, $port);
- }
-
}
diff --git a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementShellWorkflow.php b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementShellWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementShellWorkflow.php
@@ -0,0 +1,38 @@
+<?php
+
+final class PhabricatorStorageManagementShellWorkflow
+ extends PhabricatorStorageManagementWorkflow {
+
+ protected function didConstruct() {
+ $this
+ ->setName('shell')
+ ->setExamples('**shell** [__options__]')
+ ->setSynopsis('Launch an interactive shell.');
+ }
+
+ public function execute(PhutilArgumentParser $args) {
+ $api = $this->getAPI();
+ list($host, $port) = $this->getBareHostAndPort($api->getHost());
+
+ $flag_port = $port
+ ? csprintf('--port %d', $port)
+ : '';
+
+ $flag_password = '';
+ $password = $api->getPassword();
+ if ($password) {
+ if (strlen($password->openEnvelope())) {
+ $flag_password = csprintf('--password=%P', $password);
+ }
+ }
+
+ return phutil_passthru(
+ 'mysql --default-character-set=utf8 '.
+ '-u %s %C -h %s %C',
+ $api->getUser(),
+ $flag_password,
+ $host,
+ $flag_port);
+ }
+
+}
diff --git a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
--- a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
+++ b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementWorkflow.php
@@ -663,4 +663,19 @@
return 2;
}
+ protected final function getBareHostAndPort($host) {
+ // Split out port information, since the command-line client requires a
+ // separate flag for the port.
+ $uri = new PhutilURI('mysql://'.$host);
+ if ($uri->getPort()) {
+ $port = $uri->getPort();
+ $bare_hostname = $uri->getDomain();
+ } else {
+ $port = null;
+ $bare_hostname = $host;
+ }
+
+ return array($bare_hostname, $port);
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 1:04 AM (14 h, 58 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6920031
Default Alt Text
D11548.id27828.diff (4 KB)

Event Timeline