diff options
-rw-r--r-- | core/Config.php | 12 | ||||
-rw-r--r-- | core/Updater.php | 7 | ||||
-rw-r--r-- | core/Updater/Migration/Plugin/Activate.php | 6 | ||||
-rw-r--r-- | core/Updater/Migration/Plugin/Deactivate.php | 6 | ||||
-rw-r--r-- | plugins/CoreUpdater/Controller.php | 31 | ||||
-rw-r--r-- | plugins/CoreUpdater/javascripts/updateLayout.js | 2 | ||||
-rw-r--r-- | plugins/CoreUpdater/lang/en.json | 8 | ||||
-rw-r--r-- | plugins/CoreUpdater/templates/runUpdaterAndExit_welcome.twig | 11 | ||||
-rw-r--r-- | plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main.png | 4 | ||||
-rw-r--r-- | plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main_instance.png | 4 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php | 2 |
11 files changed, 71 insertions, 22 deletions
diff --git a/core/Config.php b/core/Config.php index 7d3d79a5ee..4f2d6f33cd 100644 --- a/core/Config.php +++ b/core/Config.php @@ -120,6 +120,16 @@ class Config } /** + * Returns default absolute path to the local configuration file. + * + * @return string + */ + public static function getDefaultLocalConfigPath() + { + return PIWIK_USER_PATH . self::DEFAULT_LOCAL_CONFIG_PATH; + } + + /** * Returns absolute path to the local configuration file * * @return string @@ -130,7 +140,7 @@ class Config if ($path) { return $path; } - return PIWIK_USER_PATH . self::DEFAULT_LOCAL_CONFIG_PATH; + return self::getDefaultLocalConfigPath(); } private static function getLocalConfigInfoForHostname($hostname) diff --git a/core/Updater.php b/core/Updater.php index 2bb6ebcb2d..9af07459b2 100644 --- a/core/Updater.php +++ b/core/Updater.php @@ -222,7 +222,7 @@ class Updater /** * Returns the list of SQL queries that would be executed during the update * - * @return Sql[] of SQL queries + * @return Migration[] of SQL queries * @throws \Exception */ public function getSqlQueriesToExecute() @@ -250,10 +250,7 @@ class Updater $migrationsForComponent = $update->getMigrations($this); foreach ($migrationsForComponent as $index => $migration) { $migration = $this->keepBcForOldMigrationQueryFormat($index, $migration); - - if ($migration instanceof Migration\Db) { - $queries[] = $migration; - } + $queries[] = $migration; } $this->hasMajorDbUpdate = $this->hasMajorDbUpdate || call_user_func(array($className, 'isMajorUpdate')); } diff --git a/core/Updater/Migration/Plugin/Activate.php b/core/Updater/Migration/Plugin/Activate.php index 7e904bcb2f..0c2c0b6afa 100644 --- a/core/Updater/Migration/Plugin/Activate.php +++ b/core/Updater/Migration/Plugin/Activate.php @@ -7,6 +7,7 @@ */ namespace Piwik\Updater\Migration\Plugin; +use Piwik\Config; use Piwik\Plugin; use Piwik\Updater\Migration; @@ -33,7 +34,10 @@ class Activate extends Migration public function __toString() { - return sprintf('Activating plugin "%s"', $this->pluginName); + $domain = Config::getLocalConfigPath() == Config::getDefaultLocalConfigPath() ? '' : Config::getHostname(); + $domainArg = !empty($domain) ? "--matomo-domain=\"$domain\" " : ''; + + return sprintf('./console %splugin:activate "%s"', $domainArg, $this->pluginName); } public function shouldIgnoreError($exception) diff --git a/core/Updater/Migration/Plugin/Deactivate.php b/core/Updater/Migration/Plugin/Deactivate.php index e5ced0a5a9..906e919080 100644 --- a/core/Updater/Migration/Plugin/Deactivate.php +++ b/core/Updater/Migration/Plugin/Deactivate.php @@ -7,6 +7,7 @@ */ namespace Piwik\Updater\Migration\Plugin; +use Piwik\Config; use Piwik\Plugin; use Piwik\Updater\Migration; @@ -33,7 +34,10 @@ class Deactivate extends Migration public function __toString() { - return sprintf('Deactivating plugin "%s"', $this->pluginName); + $domain = Config::getLocalConfigPath() == Config::getDefaultLocalConfigPath() ? '' : Config::getHostname(); + $domainArg = !empty($domain) ? "--matomo-domain=\"$domain\" " : ''; + + return sprintf('./console %splugin:deactivate "%s"', $domainArg, $this->pluginName); } public function shouldIgnoreError($exception) diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index db9739e319..c2f50285f1 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -29,6 +29,7 @@ use Piwik\Updater as DbUpdater; use Piwik\Version; use Piwik\View; use Piwik\View\OneClickDone; +use Piwik\Updater\Migration\Db as DbMigration; class Controller extends \Piwik\Plugin\Controller { @@ -255,7 +256,12 @@ class Controller extends \Piwik\Plugin\Controller } if ($doDryRun) { - $viewWelcome->queries = $updater->getSqlQueriesToExecute(); + $migrations = $updater->getSqlQueriesToExecute(); + $queryCount = count($migrations); + + $migrations = $this->groupMigrations($migrations); + $viewWelcome->migrations = $migrations; + $viewWelcome->queryCount = $queryCount; $viewWelcome->isMajor = $updater->hasMajorDbUpdate(); $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile); return $viewWelcome->render(); @@ -274,6 +280,29 @@ class Controller extends \Piwik\Plugin\Controller exit; } + private function groupMigrations($migrations) + { + $result = []; + + $group = null; + foreach ($migrations as $migration) { + $type = $migration instanceof DbMigration ? 'sql' : 'command'; + if ($group === null + || $type != $group['type'] + ) { + $group = [ + 'type' => $type, + 'migrations' => [], + ]; + $result[] = $group; + } + + $result[count($result) - 1]['migrations'][] = $migration; + } + + return $result; + } + private function doWelcomeUpdates($view, $componentsWithUpdateFile) { $view->new_piwik_version = Version::VERSION; diff --git a/plugins/CoreUpdater/javascripts/updateLayout.js b/plugins/CoreUpdater/javascripts/updateLayout.js index bffd8181f7..2947970afe 100644 --- a/plugins/CoreUpdater/javascripts/updateLayout.js +++ b/plugins/CoreUpdater/javascripts/updateLayout.js @@ -1,7 +1,7 @@ $(document).ready(function () { $('#showSql').click(function (e) { e.preventDefault(); - $('#sqlQueries').toggle(); + $('.sqlQueries').toggle(); }); $('#upgradeCorePluginsForm').submit(function () { $('input[type=submit]', this) diff --git a/plugins/CoreUpdater/lang/en.json b/plugins/CoreUpdater/lang/en.json index ca642d15db..1fc8cb454e 100644 --- a/plugins/CoreUpdater/lang/en.json +++ b/plugins/CoreUpdater/lang/en.json @@ -1,7 +1,7 @@ { "CoreUpdater": { "CheckingForPluginUpdates": "Checking for new plugin updates", - "ClickHereToViewSqlQueries": "Click here to view and copy the list of SQL queries that will get executed", + "ClickHereToViewSqlQueries": "Click here to view and copy the list of SQL queries and console commands that will get executed", "CriticalErrorDuringTheUpgradeProcess": "Critical Error during the update process:", "DatabaseUpgradeRequired": "Database Upgrade Required", "DisablingIncompatiblePlugins": "Disabling incompatible plugins: %s", @@ -31,7 +31,9 @@ "Latest2XStableRelease": "Latest stable 2.X", "Latest2XBetaRelease": "Latest beta 2.X", "LtsSupportVersion": "Long Term Support version", - "ListOfSqlQueriesFYI": "FYI: these are the SQL queries that will be executed to upgrade your database to Matomo %s", + "ListOfSqlQueriesFYI": "FYI: these are the SQL queries and console commands that will be executed to upgrade your database to Matomo %s", + "TheseSqlQueriesWillBeExecuted": "These SQL queries will be executed:", + "TheseCommandsWillBeExecuted": "These console commands will be run:", "MajorUpdateWarning1": "This is a major update! It will take longer than usual.", "MajorUpdateWarning2": "The following advice is especially important for large installations.", "NeedHelpUpgrading": "Need help upgrading Matomo?", @@ -75,7 +77,7 @@ "DbUpgradeNotExecuted": "Database upgrade not executed.", "ConsoleUpdateUnexpectedUserWarning": "It appears you have executed this update with user %1$s, while your Matomo files are owned by %2$s. \n\nTo ensure that the Matomo 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$ %3$s", "ConsoleUpdateFailure": "Matomo could not be updated! See above for more information.", - "ConsoleUpdateNoSqlQueries": "Note: There are no SQL queries to execute.", + "ConsoleUpdateNoSqlQueries": "Note: There are no SQL queries or console commands to execute.", "AlreadyUpToDate": "Everything is already up to date.", "ExecuteDbUpgrade": "A database upgrade is required. Execute update?", "DryRun": "Note: this is a Dry Run", diff --git a/plugins/CoreUpdater/templates/runUpdaterAndExit_welcome.twig b/plugins/CoreUpdater/templates/runUpdaterAndExit_welcome.twig index 041dacccb7..a855fd6952 100644 --- a/plugins/CoreUpdater/templates/runUpdaterAndExit_welcome.twig +++ b/plugins/CoreUpdater/templates/runUpdaterAndExit_welcome.twig @@ -53,11 +53,14 @@ <pre>{{ commandUpgradePiwik }}</pre> <p>{{ 'CoreUpdater_HighTrafficPiwikServerEnableMaintenance'|translate('<a target="_blank" rel="noreferrer noopener" href="https://matomo.org/faq/how-to/#faq_111">', '</a>')|raw }}</p> - {% if queries is not empty %} + {% if migrations is not empty %} + <p>{{ 'CoreUpdater_ListOfSqlQueriesFYI'|translate(piwik_version) }}</p> <p><a href="#" id="showSql">› {{ 'CoreUpdater_ClickHereToViewSqlQueries'|translate }}</a></p> - <div id="sqlQueries" style="display:none;"> - <pre># {{ 'CoreUpdater_ListOfSqlQueriesFYI'|translate(piwik_version) }}<br/>{% for query in queries %}{{ query }}<br/>{% endfor %}</pre> + {% for group in migrations %} + <div class="sqlQueries" style="display:none;"> + <pre># {% if group.type == 'sql' %}{{ 'CoreUpdater_TheseSqlQueriesWillBeExecuted'|translate }}{% else %}{{ 'CoreUpdater_TheseCommandsWillBeExecuted'|translate }}{% endif %} <br/>{% for migration in group.migrations %}{{ migration }}<br/>{% endfor %}</pre> </div> + {% endfor %} {% endif %} <h2>{{ 'CoreUpdater_NeedHelpUpgrading'|translate }}</h2> @@ -79,7 +82,7 @@ {% if coreToUpdate or pluginNamesToUpdate|length > 0 or dimensionsToUpdate|length > 0 %} <form action="index.php" id="upgradeCorePluginsForm" class="clearfix" data-updating="{{ 'CoreUpdater_Updating'|translate }}..."> <input type="hidden" name="updateCorePlugins" value="1"/> - {% if queries|length == 1 %} + {% if queryCount == 1 %} <input type="submit" class="btn right" value="{{ 'General_ContinueToPiwik'|translate }}"/> {% else %} <input type="submit" class="btn right" value="{{ 'CoreUpdater_UpgradePiwik'|translate }}"/> diff --git a/plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main.png b/plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main.png index 64a8a076a1..0806c0cb64 100644 --- a/plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main.png +++ b/plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:89a13a7a03740edbef58a8d6d41e28a1e1a62a38637b2b72d53f096a1ec6522b -size 292252 +oid sha256:c6d782438f1fb12fcc1e4ab18ae71eb431172faac14c3232d9133758952f1ae7 +size 306036 diff --git a/plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main_instance.png b/plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main_instance.png index 89562308f8..da8551d607 100644 --- a/plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main_instance.png +++ b/plugins/CoreUpdater/tests/UI/expected-screenshots/CoreUpdaterDb_main_instance.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2693bb08a4624b6e930a8c045886a586d43a1c89cbb9e804fe01f022d0e4c6d5 -size 294156 +oid sha256:600c26506ce387821e8df5aa82532aedd0fc43957389879d03d27bac3a25b63b +size 307931 diff --git a/tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php b/tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php index 13336b5d4d..1ca80eb4e1 100644 --- a/tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php +++ b/tests/PHPUnit/Integration/Updater/Migration/Plugin/FactoryTest.php @@ -44,7 +44,7 @@ class FactoryTest extends IntegrationTestCase { $migration = $this->factory->activate($this->pluginName); - $this->assertSame('Activating plugin "MyTestPluginName"', '' . $migration); + $this->assertSame('./console plugin:activate "MyTestPluginName"', '' . $migration); } } |