Skip to content

Instantly share code, notes, and snippets.

@totten
Created December 19, 2016 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save totten/cf76679b4fabdae4c86e06f8c0988b23 to your computer and use it in GitHub Desktop.
Save totten/cf76679b4fabdae4c86e06f8c0988b23 to your computer and use it in GitHub Desktop.
diff --git a/Civi/API/ExternalBatch.php b/Civi/API/ExternalBatch.php
index 1ff9282..2e98ad8 100644
--- a/Civi/API/ExternalBatch.php
+++ b/Civi/API/ExternalBatch.php
@@ -184,6 +184,18 @@ class ExternalBatch {
if (!$php) {
throw new \CRM_Core_Exception("Failed to locate PHP interpreter.");
}
+
+ $env = array_merge($this->env, array(
+ 'CIVICRM_SETTINGS' => $this->settingsPath,
+ ));
+ if (!empty($env)) {
+ $parts[] = 'export';
+ foreach ($env as $k => $v) {
+ $parts[] = escapeshellarg("$k=$v");
+ }
+ $parts[] = ';';
+ }
+
$parts[] = $php;
$parts[] = escapeshellarg($this->root . '/bin/cli.php');
@@ -196,10 +208,7 @@ class ExternalBatch {
}
$command = implode(" ", $parts);
- $env = array_merge($this->env, array(
- 'CIVICRM_SETTINGS' => $this->settingsPath,
- ));
- return new Process($command, $this->root, $env);
+ return new Process($command, $this->root);
}
/**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment