From 97508fa8eea13e3f383ca21b89eb70d79958ea30 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Tue, 7 Aug 2018 15:57:55 -0700 Subject: [PATCH 1/6] Do not use mysql time when setting ts password modified initial date. --- core/Updates/3.6.0-b2.php | 1 - core/Updates/3.6.0-b4.php | 42 +++++++++++++++++++++++++++++++++++++++ core/Version.php | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 core/Updates/3.6.0-b4.php diff --git a/core/Updates/3.6.0-b2.php b/core/Updates/3.6.0-b2.php index c58b9adb403..2cf068e7198 100644 --- a/core/Updates/3.6.0-b2.php +++ b/core/Updates/3.6.0-b2.php @@ -71,7 +71,6 @@ public function getMigrations(Updater $updater) // changes for session auth $migrations[] = $this->migration->db->addColumn('user', 'ts_password_modified', 'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP'); - $migrations[] = $this->migration->db->sql('UPDATE ' . Common::prefixTable('user') . ' SET ts_password_modified = NOW()'); return $migrations; } diff --git a/core/Updates/3.6.0-b4.php b/core/Updates/3.6.0-b4.php new file mode 100644 index 00000000000..19d6915e587 --- /dev/null +++ b/core/Updates/3.6.0-b4.php @@ -0,0 +1,42 @@ +migration = $factory; + } + + public function getMigrations(Updater $updater) + { + // use php date since mysql date/time might be different and might lock users out for a while. and subtract days just to be safe. + $passwordModified = Date::factory('now')->subDay(14); + return array( + $this->migration->db->sql('UPDATE ' . Common::prefixTable('user') . ' SET ts_password_modified = ' . $passwordModified), + ); + } + + public function doUpdate(Updater $updater) + { + $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); + } +} diff --git a/core/Version.php b/core/Version.php index ceb93b26f07..248be66c814 100644 --- a/core/Version.php +++ b/core/Version.php @@ -20,7 +20,7 @@ final class Version * The current Matomo version. * @var string */ - const VERSION = '3.6.0-b3'; + const VERSION = '3.6.0-b4'; public function isStableVersion($version) { From aa17b3a2e780ed57f57ae86f25fc16d8b020e423 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Tue, 7 Aug 2018 16:07:57 -0700 Subject: [PATCH 2/6] Correct namespace --- core/Updates/3.6.0-b4.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Updates/3.6.0-b4.php b/core/Updates/3.6.0-b4.php index 19d6915e587..d4c14852db6 100644 --- a/core/Updates/3.6.0-b4.php +++ b/core/Updates/3.6.0-b4.php @@ -7,9 +7,12 @@ * */ -namespace Piwik; +namespace Piwik\Updates; +use Piwik\Common; use Piwik\Updater\Migration\Factory as MigrationFactory; +use Piwik\Updates; +use Piwik\Updater; /** * Update for version 3.6.0-b4. From 73a85b4a3ed7e2310b978a1d91c768d2a1e0054a Mon Sep 17 00:00:00 2001 From: diosmosis Date: Tue, 7 Aug 2018 16:09:10 -0700 Subject: [PATCH 3/6] Missing import --- core/Updates/3.6.0-b4.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Updates/3.6.0-b4.php b/core/Updates/3.6.0-b4.php index d4c14852db6..eb0ce2fe165 100644 --- a/core/Updates/3.6.0-b4.php +++ b/core/Updates/3.6.0-b4.php @@ -10,6 +10,7 @@ namespace Piwik\Updates; use Piwik\Common; +use Piwik\Date; use Piwik\Updater\Migration\Factory as MigrationFactory; use Piwik\Updates; use Piwik\Updater; From 0ff5f980c15501ebbef139803997edebc5a34e85 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Tue, 7 Aug 2018 16:11:10 -0700 Subject: [PATCH 4/6] fix sql --- core/Updates/3.6.0-b4.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Updates/3.6.0-b4.php b/core/Updates/3.6.0-b4.php index eb0ce2fe165..b6b91c8ecaa 100644 --- a/core/Updates/3.6.0-b4.php +++ b/core/Updates/3.6.0-b4.php @@ -35,7 +35,7 @@ public function getMigrations(Updater $updater) // use php date since mysql date/time might be different and might lock users out for a while. and subtract days just to be safe. $passwordModified = Date::factory('now')->subDay(14); return array( - $this->migration->db->sql('UPDATE ' . Common::prefixTable('user') . ' SET ts_password_modified = ' . $passwordModified), + $this->migration->db->sql('UPDATE ' . Common::prefixTable('user') . ' SET ts_password_modified = "' . $passwordModified->getDatetime() . '"'), ); } From 302814e40528511baa40d0fa07e0d4b527994b47 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Wed, 8 Aug 2018 12:36:11 -0700 Subject: [PATCH 5/6] Make ts_password_modified column nullable so when eventually displayed, will not result in an inaccurate display. --- core/Db/Schema/Mysql.php | 2 +- core/Updates/3.6.0-b4.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/core/Db/Schema/Mysql.php b/core/Db/Schema/Mysql.php index f517edf6cc4..d483762b6fe 100644 --- a/core/Db/Schema/Mysql.php +++ b/core/Db/Schema/Mysql.php @@ -41,7 +41,7 @@ public function getTablesCreateSql() token_auth CHAR(32) NOT NULL, superuser_access TINYINT(2) unsigned NOT NULL DEFAULT '0', date_registered TIMESTAMP NULL, - ts_password_modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + ts_password_modified TIMESTAMP NULL, PRIMARY KEY(login), UNIQUE KEY uniq_keytoken(token_auth) ) ENGINE=$engine DEFAULT CHARSET=utf8 diff --git a/core/Updates/3.6.0-b4.php b/core/Updates/3.6.0-b4.php index b6b91c8ecaa..eb4c0723c3e 100644 --- a/core/Updates/3.6.0-b4.php +++ b/core/Updates/3.6.0-b4.php @@ -10,7 +10,6 @@ namespace Piwik\Updates; use Piwik\Common; -use Piwik\Date; use Piwik\Updater\Migration\Factory as MigrationFactory; use Piwik\Updates; use Piwik\Updater; @@ -32,10 +31,9 @@ public function __construct(MigrationFactory $factory) public function getMigrations(Updater $updater) { - // use php date since mysql date/time might be different and might lock users out for a while. and subtract days just to be safe. - $passwordModified = Date::factory('now')->subDay(14); return array( - $this->migration->db->sql('UPDATE ' . Common::prefixTable('user') . ' SET ts_password_modified = "' . $passwordModified->getDatetime() . '"'), + $this->migration->db->changeColumn('user', 'ts_password_modified', 'ts_password_modified', 'ts_password_modified TIMESTAMP NULL'), + $this->migration->db->sql('UPDATE `' . Common::prefixTable('user') . '` SET ts_password_modified = NULL'), ); } From af58fc2ed6807d330ac534b85c2dc16dafacd229 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Wed, 8 Aug 2018 12:38:55 -0700 Subject: [PATCH 6/6] fix update --- core/Updates/3.6.0-b4.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Updates/3.6.0-b4.php b/core/Updates/3.6.0-b4.php index eb4c0723c3e..a74204bd2f0 100644 --- a/core/Updates/3.6.0-b4.php +++ b/core/Updates/3.6.0-b4.php @@ -32,7 +32,7 @@ public function __construct(MigrationFactory $factory) public function getMigrations(Updater $updater) { return array( - $this->migration->db->changeColumn('user', 'ts_password_modified', 'ts_password_modified', 'ts_password_modified TIMESTAMP NULL'), + $this->migration->db->changeColumn('user', 'ts_password_modified', 'ts_password_modified', 'TIMESTAMP NULL'), $this->migration->db->sql('UPDATE `' . Common::prefixTable('user') . '` SET ts_password_modified = NULL'), ); }