Piwik\Filechecks::getCommandToChangeOwnerOfPiwikFiles PHP Method

getCommandToChangeOwnerOfPiwikFiles() public static method

    public static function getCommandToChangeOwnerOfPiwikFiles()
    {
        $realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
        return "chown -R " . self::getUserAndGroup() . " " . $realpath;
    }

Usage Example

Example #1
0
 /**
  * @param OutputInterface $output
  */
 protected function writeAlertMessageWhenCommandExecutedWithUnexpectedUser(OutputInterface $output)
 {
     if (SettingsServer::isWindows()) {
         // does not work on windows
         return;
     }
     $processUserAndGroup = Filechecks::getUserAndGroup();
     $fileOwnerUserAndGroup = Filechecks::getOwnerOfPiwikFiles();
     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, Filechecks::getCommandToChangeOwnerOfPiwikFiles()));
 }