diff --git a/core/Filechecks.php b/core/Filechecks.php index 387fa244ca6f82afb7df695f4264d68ed119e9bd..33e65c9055e3d64af233e9d41a440f631239f8e9 100644 --- a/core/Filechecks.php +++ b/core/Filechecks.php @@ -310,11 +310,19 @@ class Filechecks return ''; } - $group = posix_getgrgid($stat[5]); - $group = $group['name']; + if (function_exists('posix_getgrgid')) { + $group = posix_getgrgid($stat[5]); + $group = $group['name']; + } else { + return ''; + } - $user = posix_getpwuid($stat[4]); - $user = $user['name']; + if (function_exists('posix_getpwuid')) { + $user = posix_getpwuid($stat[4]); + $user = $user['name']; + } else { + return ''; + } return "$user:$group"; } diff --git a/plugins/CoreUpdater/Commands/Update.php b/plugins/CoreUpdater/Commands/Update.php index be2c105e93e9f7ea119593da7c8efead0bc44353..5756bd02aa853429649fdda5825965cdd12adc91 100644 --- a/plugins/CoreUpdater/Commands/Update.php +++ b/plugins/CoreUpdater/Commands/Update.php @@ -358,7 +358,7 @@ class Update extends ConsoleCommand */ protected function writeAlertMessageWhenCommandExecutedWithUnexpectedUser(OutputInterface $output) { - if(SettingsServer::isWindows()) { + if (SettingsServer::isWindows()) { // does not work on windows return; } @@ -366,12 +366,11 @@ class Update extends ConsoleCommand $processUserAndGroup = Filechecks::getUserAndGroup(); $fileOwnerUserAndGroup = Filechecks::getOwnerOfPiwikFiles(); - if($processUserAndGroup == $fileOwnerUserAndGroup) { + if (!$fileOwnerUserAndGroup || $processUserAndGroup == $fileOwnerUserAndGroup) { // current process user/group appear to be same as the Piwik filesystem user/group -> OK return; } $output->writeln( - sprintf("<comment>It appears you have executed this update with user %s, while your Piwik files are owned by %s. \n\nTo ensure that the Piwik files are readable by the correct user, you may need to run the following command (or a similar command depending on your server configuration):\n\n$ %s</comment>", $processUserAndGroup, $fileOwnerUserAndGroup,