Skip to content
Extraits de code Groupes Projets
Valider 3fcead8b rédigé par Matthieu Aubry's avatar Matthieu Aubry Validation de GitHub
Parcourir les fichiers

Fixes #10143 (#10424)

parent 77a6412f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -174,7 +174,7 @@ class Filechecks ...@@ -174,7 +174,7 @@ class Filechecks
{ {
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/'); $realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
$message = ''; $message = '';
$message .= "<code>chown -R ". self::getUserAndGroup() ." " . $realpath . "</code><br />"; $message .= "<code>" . self::getCommandToChangeOwnerOfPiwikFiles() . "</code><br />";
$message .= "<code>chmod -R 0755 " . $realpath . "</code><br />"; $message .= "<code>chmod -R 0755 " . $realpath . "</code><br />";
$message .= 'After you execute these commands (or change permissions via your FTP software), refresh the page and you should be able to use the "Automatic Update" feature.'; $message .= 'After you execute these commands (or change permissions via your FTP software), refresh the page and you should be able to use the "Automatic Update" feature.';
return $message; return $message;
...@@ -247,4 +247,30 @@ class Filechecks ...@@ -247,4 +247,30 @@ class Filechecks
} }
return "<code>chmod -R 0755 $realpath</code><br />"; return "<code>chmod -R 0755 $realpath</code><br />";
} }
/**
* @return string
*/
public static function getCommandToChangeOwnerOfPiwikFiles()
{
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
return "chown -R " . self::getUserAndGroup() . " " . $realpath;
}
public static function getOwnerOfPiwikFiles()
{
$index = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/index.php');
$stat = stat($index);
if(!$stat) {
return '';
}
$group = posix_getgrgid($stat[5]);
$group = $group['name'];
$user = posix_getpwuid($stat[4]);
$user = $user['name'];
return "$user:$group";
}
} }
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
*/ */
namespace Piwik\Plugins\CoreUpdater\Commands; namespace Piwik\Plugins\CoreUpdater\Commands;
use Piwik\Filechecks;
use Piwik\SettingsServer;
use Piwik\Version; use Piwik\Version;
use Piwik\Config; use Piwik\Config;
use Piwik\DbHelper; use Piwik\DbHelper;
...@@ -68,6 +70,9 @@ class Update extends ConsoleCommand ...@@ -68,6 +70,9 @@ class Update extends ConsoleCommand
$this->writeSuccessMessage($output, array('Database upgrade not executed.')); $this->writeSuccessMessage($output, array('Database upgrade not executed.'));
} }
$this->writeAlertMessageWhenCommandExecutedWithUnexpectedUser($output);
} catch(NoUpdatesFoundException $e) { } catch(NoUpdatesFoundException $e) {
// Do not fail if no updates were found // Do not fail if no updates were found
$this->writeSuccessMessage($output, array($e->getMessage())); $this->writeSuccessMessage($output, array($e->getMessage()));
...@@ -153,6 +158,11 @@ class Update extends ConsoleCommand ...@@ -153,6 +158,11 @@ class Update extends ConsoleCommand
{ {
$migrationQueries = $this->getMigrationQueriesToExecute($updater); $migrationQueries = $this->getMigrationQueriesToExecute($updater);
if(empty($migrationQueries)) {
$output->writeln(array(" *** Note: There are no SQL queries to execute. ***", ""));
return;
}
$output->writeln(array(" *** Note: this is a Dry Run ***", "")); $output->writeln(array(" *** Note: this is a Dry Run ***", ""));
foreach ($migrationQueries as $query) { foreach ($migrationQueries as $query) {
...@@ -334,4 +344,31 @@ class Update extends ConsoleCommand ...@@ -334,4 +344,31 @@ class Update extends ConsoleCommand
return $updater; return $updater;
} }
/**
* @param OutputInterface $output
*/
protected function writeAlertMessageWhenCommandExecutedWithUnexpectedUser(OutputInterface $output)
{
if(SettingsServer::isWindows()) {
// does not work on windows
return;
}
$processUserAndGroup = Filechecks::getUserAndGroup();
$fileOwnerUserAndGroup = Filechecks::getOwnerOfPiwikFiles();
if($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()
)
);
}
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter