Commit 1290095b authored by Marc Egger's avatar Marc Egger

ColumnScript.php: write return variables in VARS store instead of CLIENT

parent d17c8ee1
Pipeline #3838 passed with stages
in 4 minutes and 15 seconds
......@@ -1428,7 +1428,7 @@ Run a php function defined in an external script.
* 'e' : returns ''
* The current working directory is the current web instance (e.g. ``/var/www/html``) .
* All output (e.g. using echo) will be returned by the special column as is.
* If the function returns an associative array, then the key-value pairs will be accessible via the Client store.
* If the function returns an associative array, then the key-value pairs will be accessible via the VARS store `V`.
* Text sent to 'stderr' by the php function is not returned at all.
**Column Parameters**
......@@ -1460,15 +1460,15 @@ Run a php function defined in an external script.
list($http_code, $answer) = $qfq::apiCall('GET', 'google.com');
echo 'Http code: ' . $http_code;
// Returned array fills client store
return ["IAmInClientStore" => "FooBar"];
// Returned array fills VARS store
return ["IAmInVarStore" => "FooBar"];
}
* QFQ report ::
5.sql = SELECT "IAmInRecordStore" AS _savedInRecordStore
10.sql = SELECT "F:fileadmin/scripts/my_script.php|c:my_function|a1:Hello|a2:World" AS _script
20.sql = SELECT "<br><br>Returened value: {{IAmInClientStore:C:alnumx}}"
20.sql = SELECT "<br><br>Returened value: {{IAmInVarStore:V:alnumx}}"
* Output ::
......
......@@ -11,8 +11,8 @@ use IMATHUZH\Qfq\Core\Store\Store;
* @package IMATHUZH\Qfq\Core\Report
*
* Executes a function of an external script. Column parameters:
* scr: path to script
* f: function name
* F: path to script
* c: function name
*
* All parameters are passed to the function as the first argument.
* The second argument passed is an instance of ScriptFunctions which acts as an interface to QFQ functionality.
......@@ -61,7 +61,10 @@ class ColumnScript {
}
// return buffer output and fill store
Store::setStore($return, STORE_CLIENT, true);
if (is_array($return)) {
$returnNoArrays = array_filter($return, function ($value) {return !is_array($value);});
Store::appendToStore($returnNoArrays, STORE_VAR);
}
return $output;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment