Skip to content

Commit

Permalink
Remove most of sitealias.inc. (#2979)
Browse files Browse the repository at this point in the history
* Remove most of sitealias.inc.

* Put back drush_convert_db_from_db_url(), as we are still using it.

* Put back drush_sitealias_is_remote_site

* Split DrupalDirectoryCommands out of CoreCommands, and fix bug with local directory paths.
  • Loading branch information
greg-1-anderson authored Sep 28, 2017
1 parent e9bd694 commit 7457172
Show file tree
Hide file tree
Showing 13 changed files with 223 additions and 2,387 deletions.
4 changes: 2 additions & 2 deletions includes/bootstrap.inc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function _drush_bootstrap_selected_uri() {
}
$uri = 'http://'. $current;
$uri = drush_set_context('DRUSH_SELECTED_URI', $uri);
drush_sitealias_create_self_alias();
// drush_sitealias_create_self_alias();
}

return $uri;
Expand Down Expand Up @@ -249,7 +249,7 @@ function drush_bootstrap_max($max_phase_index = FALSE) {
*/
function drush_bootstrap_max_to_sitealias($site_record, $max_phase_index = NULL) {
if ((array_key_exists('root', $site_record) && !array_key_exists('remote-host', $site_record))) {
drush_sitealias_set_alias_context($site_record);
// drush_sitealias_set_alias_context($site_record);
drush_bootstrap_max($max_phase_index);
return TRUE;
}
Expand Down
10 changes: 0 additions & 10 deletions includes/exec.inc
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,6 @@ function legacy_drush_os($site_record = NULL) {
return $os;
}

/**
* Determine the remote host ([email protected]) for
* the specified site.
*/
function drush_remote_host($site, $prefix = '') {
$hostname = drush_escapeshellarg(drush_sitealias_get_option($site, 'remote-host', '', $prefix), "LOCAL");
$username = drush_escapeshellarg(drush_sitealias_get_option($site, 'remote-user', '', $prefix), "LOCAL");
return $username . (empty($username) ? '' : '@') . $hostname;
}

/**
* Make an attempt to simply wrap the arg with the
* kind of quote characters it does not already contain.
Expand Down
68 changes: 54 additions & 14 deletions includes/legacy.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use Drush\Sql\SqlBase;
* versions. If they aren't working for you, consider upgrading your commandfile
* so that it works with modern Drush.
*
* @deprecated
* @deprecated
*/

// @deprecated
Expand All @@ -21,19 +21,6 @@ function drush_sql_get_class($db_spec = NULL) {
return SqlBase::create($options);
}

/**
* Given an alias record, overwrite its values with options
* from the command line and other drush contexts as specified
* by the provided prefix. For example, if the prefix is 'source-',
* then any option 'source-foo' will set the value 'foo' in the
* alias record.
*
* @deprecated
*/
function drush_sitealias_overlay_options($site_alias_record, $prefix) {
return array_merge($site_alias_record, drush_get_merged_prefixed_options($prefix));
}

/**
* Retrieves a collapsed list of all options
* with a specified prefix.
Expand Down Expand Up @@ -296,3 +283,56 @@ function drush_table_column_autowidth($rows, $widths) {
return $auto_widths;
}

/**
* Convert from an old-style database URL to an array of database settings.
*
* @param db_url
* A Drupal 6 db url string to convert, or an array with a 'default' element.
* @return array
* An array of database values containing only the 'default' element of
* the db url. If the parse fails the array is empty.
*/
function drush_convert_db_from_db_url($db_url) {
$db_spec = array();

if (is_array($db_url)) {
$db_url_default = $db_url['default'];
}
else {
$db_url_default = $db_url;
}

// If it's a sqlite database, pick the database path and we're done.
if (strpos($db_url_default, 'sqlite://') === 0) {
$db_spec = array(
'driver' => 'sqlite',
'database' => substr($db_url_default, strlen('sqlite://')),
);
}
else {
$url = parse_url($db_url_default);
if ($url) {
// Fill in defaults to prevent notices.
$url += array(
'scheme' => NULL,
'user' => NULL,
'pass' => NULL,
'host' => NULL,
'port' => NULL,
'path' => NULL,
);
$url = (object)array_map('urldecode', $url);
$db_spec = array(
'driver' => $url->scheme == 'mysqli' ? 'mysql' : $url->scheme,
'username' => $url->user,
'password' => $url->pass,
'host' => $url->host,
'port' => $url->port,
'database' => ltrim($url->path, '/'),
);
}
}

return $db_spec;
}

Loading

0 comments on commit 7457172

Please sign in to comment.