You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2019/12/14 23:22:42 UTC

[openwhisk-runtime-php] 02/05: The parameters need to be set up as environment variables so that getenv() can retrieve them too

This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-runtime-php.git

commit d91e35dd9f53b1491892b236863586d8c7dd036d
Author: Rob Allen <ro...@akrabat.com>
AuthorDate: Sat Dec 14 13:45:14 2019 -0500

    The parameters need to be set up as environment variables so that
    getenv() can retrieve them too
---
 core/php7.1Action/router.php | 1 -
 core/php7.2Action/router.php | 1 -
 core/php7.3Action/runner.php | 8 ++++----
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/core/php7.1Action/router.php b/core/php7.1Action/router.php
index 1ec8ecb..eadc153 100644
--- a/core/php7.1Action/router.php
+++ b/core/php7.1Action/router.php
@@ -208,7 +208,6 @@ function run() : array
     if (array_key_exists('value', $post) && is_array($post['value'])) {
         $args = json_encode($post['value']);
     }
-    $env['WHISK_INPUT'] = $args;
 
     // run the action
     list($returnCode, $stdout, $stderr) = runPHP(
diff --git a/core/php7.2Action/router.php b/core/php7.2Action/router.php
index c3ada90..3bf01a1 100644
--- a/core/php7.2Action/router.php
+++ b/core/php7.2Action/router.php
@@ -229,7 +229,6 @@ function run() : array
     if (array_key_exists('value', $post) && is_array($post['value'])) {
         $args = $post['value'];
     }
-    $_ENV['WHISK_INPUT'] = json_encode($args);
 
     // run the action
     require __DIR__ . '/src/vendor/autoload.php';
diff --git a/core/php7.3Action/runner.php b/core/php7.3Action/runner.php
index 6941986..5923818 100755
--- a/core/php7.3Action/runner.php
+++ b/core/php7.3Action/runner.php
@@ -49,10 +49,10 @@ while ($f = fgets(STDIN)) {
 
     // convert all parameters other than value to environment variables
     foreach ($data as $key => $value) {
-        if ($key == 'value') {
-            $_ENV['WHISK_INPUT'] = $data['value'] ?? [];
-        } else {
-            $_ENV['__OW_' . strtoupper($key)] = $value;
+        if ($key !== 'value') {
+            $envKeyName = '__OW_' . strtoupper($key);
+            $_ENV[$envKeyName] = $value;
+            putenv($envKeyName . '=' . $value);
         }
     }