summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Anderson2011-08-12 00:53:09 (GMT)
committer Mark Sonnabaum2011-08-12 00:53:09 (GMT)
commit28702056ae00f8c0a3aa3d5a7c653c906529264b (patch)
tree3a1abe472f823d6fecf6e084c145ccc70a9bfd81
parent9bd1ae76f6e2a6619dd260715e6a6e173ffaddca (diff)
Issue #1245778 by greg.1.anderson: Make drush_invoke_process in drush-4.x forward-compatible with the same function in drush-5.x.7.x-4.5
-rw-r--r--includes/backend.inc10
-rw-r--r--includes/command.inc38
2 files changed, 37 insertions, 11 deletions
diff --git a/includes/backend.inc b/includes/backend.inc
index f09a7bf..fd4cb1f 100644
--- a/includes/backend.inc
+++ b/includes/backend.inc
@@ -298,7 +298,7 @@ function _drush_proc_open($cmd, $data = NULL, $context = NULL) {
* Optional. Defaults to the current user. If you specify this, you can choose which module to send.
*
* @deprecated Command name includes arguments, and these are not quote-escaped in any way.
- * @see drush_backend_invoke_args and @see drush_invoke_process for better options.
+ * @see drush_invoke_process("@self", $command, array($arg1, $arg2, ...), $data) for a better option.
*
* @return
* If the command could not be completed successfully, FALSE.
@@ -313,9 +313,8 @@ function drush_backend_invoke($command, $data = array(), $method = 'GET', $integ
/**
* A variant of drush_backend_invoke() which specifies command and arguments separately.
*
- * @deprecated Is not as extensible as drush_backend_invoke_sitealias; @see http://drupal.org/node/766080
- * @see drush_invoke_sitealias_args() and @see drush_invoke_process and
- * @see drush_backend_invoke_sitealias() for better options.
+ * @deprecated; do not call directly.
+ * @see drush_invoke_process("@self", $command, $args, $data) for a better option.
*/
function drush_backend_invoke_args($command, $args, $data = array(), $method = 'GET', $integrate = TRUE, $drush_path = NULL, $hostname = NULL, $username = NULL, $ssh_options = NULL) {
$cmd = _drush_backend_generate_command($command, $args, $data, $method, $drush_path, $hostname, $username, $ssh_options);
@@ -362,6 +361,9 @@ function drush_backend_invoke_args($command, $args, $data = array(), $method = '
*
* @return
* A text string representing a fully escaped command.
+ *
+ * @deprecated; do not call directly.
+ * @see drush_invoke_process($site_record, $command, $args, $data) for a better option.
*/
function drush_backend_invoke_sitealias($site_record, $command, $args, $data = array(), $method = 'GET', $integrate = TRUE) {
$cmd = _drush_backend_generate_command_sitealias($site_record, $command, $args, $data, $method);
diff --git a/includes/command.inc b/includes/command.inc
index c133b85..de876c5 100644
--- a/includes/command.inc
+++ b/includes/command.inc
@@ -221,20 +221,41 @@ function drush_dispatch($command, $arguments = array()) {
}
/**
- * Invoke a command in a new process.
+ * Invoke a command in a new process, targeting the site specified by
+ * the provided site alias record.
*
- * @param command_name
- * The drush command to execute.
+ * @param array $site_alias_record
+ * The site record to execute the command on.
+ * @param string $command_name
+ * The command to invoke.
+ * @param array $commandline_args
+ * The arguments to pass to the command.
+ * @param array $commandline_options
+ * The options (e.g. --select) to provide to the command.
* @return
* If the command could not be completed successfully, FALSE.
* If the command was completed, this will return an associative
* array containing the results of the API call.
* @see drush_backend_get_result()
+ *
+ * This function may also be called via its deprecated function signature
+ * (drush-3.x compatible): drush_invoke_process($command_name, $arg1, $arg2, ...);
+ * Instead of this old form, prefer: drush_invoke_process("@self", $command_name, array($arg1, $arg2, ...));
*/
-function drush_invoke_process($command_name) {
- $args = func_get_args();
- array_shift($args);
- return drush_invoke_process_args($command_name, $args);
+function drush_invoke_process($site_alias_record /*, $command_name, $commandline_args = array(), $commandline_options = array() */) {
+ if (is_array($site_alias_record)) {
+ $args = func_get_args();
+ array_shift($args);
+ $command_name = array_shift($args);
+ $commandline_args = empty($args) ? array() : array_shift($args);
+ $commandline_options = empty($args) ? array() : array_shift($args);
+ return drush_invoke_sitealias_args($site_alias_record, $command_name, $commandline_args, $commandline_options);
+ }
+ else {
+ $args = func_get_args();
+ $command_name = array_shift($args);
+ return drush_invoke_process_args($command_name, $args);
+ }
}
/**
@@ -247,6 +268,7 @@ function drush_invoke_process($command_name) {
* If the command was completed, this will return an associative
* array containing the results of the API call.
* @see drush_backend_get_result()
+ * @deprecated; @see drush_invoke_process("@self", $command_name, $commandline_args, $commandline_options) for a better option
*/
function drush_invoke_process_args($command_name, $commandline_args, $commandline_options = array()) {
return drush_backend_invoke_args($command_name, $commandline_args, $commandline_options);
@@ -265,6 +287,7 @@ function drush_invoke_process_args($command_name, $commandline_args, $commandlin
* If the command was completed, this will return an associative
* array containing the results of the API call.
* @see drush_backend_get_result()
+ * @deprecated; @see drush_invoke_process($site_alias_record, $command_name, array($arg1, $arg2, ...)) for a better option
*/
function drush_invoke_sitealias($site_alias_record, $command_name) {
$args = func_get_args();
@@ -291,6 +314,7 @@ function drush_invoke_sitealias($site_alias_record, $command_name) {
* If the command was completed, this will return an associative
* array containing the results of the API call.
* @see drush_backend_get_result()
+ * @deprecated; @see drush_invoke_process($site_alias_record, $command_name, $commandline_args, $commandline_options) for a better option
*/
function drush_invoke_sitealias_args($site_alias_record, $command_name, $commandline_args, $commandline_options = array()) {
// If the first parameter is not a site alias record,