-
Bug
-
Resolution: Fixed
-
Major
-
3.9.25, 3.11.18, 4.0.12, 4.1.8, 4.2.5, 4.3.2
We recently noticed that running scheduled task by the gui fails silently if you use any getenv in the config.php.
To reproduce:
1.have at least 1 getenv in your config.php
2. Run a schedule task from the gui, no logs will be shown
This was introduced with this fix:
https://tracker.moodle.org/browse/MDL-80309
Specificaly this line:
By passing an empty array to the env_vars options of the proc_open function, no environment variables is passed to the process (see documentation of proc_open here https://www.php.net/manual/en/function.proc-open.php)
As stderr isn't printed Moodle doesn't show any error, but you can change the code to see the error like this:
$process = proc_open($command, $descriptorspec, $pipes, realpath('./'), []); |
if (is_resource($process)) { |
echo("commmand output 2: " .stream_get_contents($pipes[2]); |
while ($s = fgets($pipes[1])) { |
mtrace($s, ''); |
flush(); |
}
|
}
|
|
This could be fixed by changing the code to:
$process = proc_open($command, $descriptorspec, $pipes, realpath('./'), null); |
Which would then pass all environment variables.
- has been marked as being related by
-
MDL-80512 Cannot redeclare tool_task_status_checks() error while trying to "Run now" cron task
- Closed