diff --git a/core/CliMulti/Process.php b/core/CliMulti/Process.php index 0985b207379..b1dbb1e3fc7 100644 --- a/core/CliMulti/Process.php +++ b/core/CliMulti/Process.php @@ -311,7 +311,7 @@ public static function getListOfRunningProcesses() */ public static function getRunningProcesses() { - $ids = explode("\n", trim(shell_exec(self::PS_COMMAND . ' 2>/dev/null | ' . self::AWK_COMMAND . ' 2>/dev/null'))); + $ids = explode("\n", trim(shell_exec(self::PS_COMMAND . ' 2>/dev/null | ' . self::AWK_COMMAND . ' 2>/dev/null') ?? '')); $ids = array_map('intval', $ids); $ids = array_filter($ids, function ($id) { diff --git a/core/Filechecks.php b/core/Filechecks.php index cd3264002fe..d7b3b651852 100644 --- a/core/Filechecks.php +++ b/core/Filechecks.php @@ -150,7 +150,7 @@ public static function getUserAndGroup() return $user . ':' . $user; } - $group = trim(shell_exec('groups ' . $user . ' | cut -f3 -d" "')); + $group = trim(shell_exec('groups ' . $user . ' | cut -f3 -d" "') ?? ''); if (empty($group) && function_exists('posix_getegid') && function_exists('posix_getgrgid')) { $currentGroupId = posix_getegid(); @@ -173,7 +173,7 @@ public static function getUserAndGroup() public static function getUser() { if (function_exists('shell_exec')) { - return trim(shell_exec('whoami')); + return trim(shell_exec('whoami') ?? ''); } $currentUser = get_current_user(); diff --git a/plugins/CoreConsole/Commands/GitCommit.php b/plugins/CoreConsole/Commands/GitCommit.php index c075d473766..8701023b672 100644 --- a/plugins/CoreConsole/Commands/GitCommit.php +++ b/plugins/CoreConsole/Commands/GitCommit.php @@ -141,7 +141,7 @@ private function getSubmodulePaths() protected function getStatusOfSubmodule($submodule) { $cmd = sprintf('cd %s/%s && git status --porcelain', PIWIK_DOCUMENT_ROOT, $submodule); - $status = trim(shell_exec($cmd)); + $status = trim(shell_exec($cmd) ?? ''); return $status; } diff --git a/plugins/TestRunner/Commands/TestsRun.php b/plugins/TestRunner/Commands/TestsRun.php index 8624ab31b8a..118aa15b6ff 100644 --- a/plugins/TestRunner/Commands/TestsRun.php +++ b/plugins/TestRunner/Commands/TestsRun.php @@ -87,7 +87,7 @@ function ($xdebugFile) { $output->writeln("using $xdebugFile as xdebug extension."); - $phpunitPath = trim(shell_exec('which phpunit')); + $phpunitPath = trim(shell_exec('which phpunit') ?? ''); $command = sprintf('php -d zend_extension=%s %s', $xdebugFile, $phpunitPath); }