From a27fa815bbcffab3352214786eb1884f55d6ffa6 Mon Sep 17 00:00:00 2001
From: Thomas Steur <tsteur@users.noreply.github.com>
Date: Thu, 3 Nov 2016 15:23:32 +1300
Subject: [PATCH] fix a posix function was called that may not exist on the
 server (#10825)

---
 core/Filechecks.php                     | 16 ++++++++++++----
 plugins/CoreUpdater/Commands/Update.php |  5 ++---
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/core/Filechecks.php b/core/Filechecks.php
index 387fa244ca..33e65c9055 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 be2c105e93..5756bd02aa 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,
-- 
GitLab