Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Aubry <mattab@users.noreply.github.com>2016-08-28 09:35:27 +0300
committerGitHub <noreply@github.com>2016-08-28 09:35:27 +0300
commit3fcead8b2bc7d6a2e26d7f1101861ea44d563aef (patch)
tree6dbe355484fd26dee5523c71fe5ae5e6f834d88d
parent77a6412ff7a8bdb2f23fb00a2d8ce22e7a35fcee (diff)
Fixes #10143 (#10424)2.16.3-b2
-rw-r--r--core/Filechecks.php28
-rw-r--r--plugins/CoreUpdater/Commands/Update.php37
2 files changed, 64 insertions, 1 deletions
diff --git a/core/Filechecks.php b/core/Filechecks.php
index 274453e96d..ee29adad7e 100644
--- a/core/Filechecks.php
+++ b/core/Filechecks.php
@@ -174,7 +174,7 @@ class Filechecks
{
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
$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 .= '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;
@@ -247,4 +247,30 @@ class Filechecks
}
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";
+ }
}
diff --git a/plugins/CoreUpdater/Commands/Update.php b/plugins/CoreUpdater/Commands/Update.php
index 4b4d79e287..14865b6c33 100644
--- a/plugins/CoreUpdater/Commands/Update.php
+++ b/plugins/CoreUpdater/Commands/Update.php
@@ -8,6 +8,8 @@
*/
namespace Piwik\Plugins\CoreUpdater\Commands;
+use Piwik\Filechecks;
+use Piwik\SettingsServer;
use Piwik\Version;
use Piwik\Config;
use Piwik\DbHelper;
@@ -68,6 +70,9 @@ class Update extends ConsoleCommand
$this->writeSuccessMessage($output, array('Database upgrade not executed.'));
}
+ $this->writeAlertMessageWhenCommandExecutedWithUnexpectedUser($output);
+
+
} catch(NoUpdatesFoundException $e) {
// Do not fail if no updates were found
$this->writeSuccessMessage($output, array($e->getMessage()));
@@ -153,6 +158,11 @@ class Update extends ConsoleCommand
{
$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 ***", ""));
foreach ($migrationQueries as $query) {
@@ -334,4 +344,31 @@ class Update extends ConsoleCommand
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()
+ )
+ );
+ }
}