From be6f8144850533408a76ae97558bb626d33c0ae4 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 3 Oct 2019 14:35:33 +0200 Subject: [PATCH 1/7] Privacy datetimes defaults - SQL changes --- .../com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql | 4 ++++ .../com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql | 5 +++++ installation/sql/mysql/joomla.sql | 6 +++--- installation/sql/postgresql/joomla.sql | 6 +++--- 4 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql create mode 100644 administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql new file mode 100644 index 0000000000000..8e7cb083fdb22 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql @@ -0,0 +1,4 @@ +ALTER TABLE `#__privacy_requests` MODIFY `requested_at` datetime NOT NULL; +ALTER TABLE `#__privacy_requests` MODIFY `confirm_token_created_at` datetime NULL DEFAULT NULL; + +ALTER TABLE `#__privacy_consents` MODIFY `created` datetime NOT NULL; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql new file mode 100644 index 0000000000000..97ba1ba3a5995 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql @@ -0,0 +1,5 @@ +ALTER TABLE "#__privacy_requests" ALTER COLUMN "requested_at" DROP DEFAULT; +ALTER TABLE "#__privacy_requests" ALTER COLUMN "confirm_token_created_at" DROP NOT NULL; +ALTER TABLE "#__privacy_requests" ALTER COLUMN "confirm_token_created_at" DROP DEFAULT; + +ALTER TABLE "#__privacy_consents" ALTER COLUMN "created" DROP DEFAULT; diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 08473ead7fefe..f867b603c2479 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -1651,11 +1651,11 @@ SELECT extension_id, 'PLG_SYSTEM_HTTPHEADERS_POSTINSTALL_INTRODUCTION_TITLE', 'P CREATE TABLE IF NOT EXISTS `#__privacy_requests` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `email` varchar(100) NOT NULL DEFAULT '', - `requested_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `requested_at` datetime NOT NULL, `status` tinyint(4) NOT NULL DEFAULT 0, `request_type` varchar(25) NOT NULL DEFAULT '', `confirm_token` varchar(100) NOT NULL DEFAULT '', - `confirm_token_created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `confirm_token_created_at` datetime, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; @@ -1669,7 +1669,7 @@ CREATE TABLE IF NOT EXISTS `#__privacy_consents` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned NOT NULL DEFAULT 0, `state` INT(10) NOT NULL DEFAULT 1, - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL, `subject` varchar(255) NOT NULL DEFAULT '', `body` text NOT NULL, `remind` tinyint(4) NOT NULL DEFAULT 0, diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index a2f245f11469c..41fed220c53e6 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -1656,11 +1656,11 @@ SELECT "extension_id", 'PLG_SYSTEM_HTTPHEADERS_POSTINSTALL_INTRODUCTION_TITLE', CREATE TABLE "#__privacy_requests" ( "id" serial NOT NULL, "email" varchar(100) DEFAULT '' NOT NULL, - "requested_at" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "requested_at" timestamp without time zone NOT NULL, "status" smallint DEFAULT 0 NOT NULL, "request_type" varchar(25) DEFAULT '' NOT NULL, "confirm_token" varchar(100) DEFAULT '' NOT NULL, - "confirm_token_created_at" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "confirm_token_created_at" timestamp without time zone, PRIMARY KEY ("id") ); @@ -1672,7 +1672,7 @@ CREATE TABLE "#__privacy_consents" ( "id" serial NOT NULL, "user_id" bigint DEFAULT 0 NOT NULL, "state" smallint DEFAULT 1 NOT NULL, - "created" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "created" timestamp without time zone NOT NULL, "subject" varchar(255) DEFAULT '' NOT NULL, "body" text NOT NULL, "remind" smallint DEFAULT 0 NOT NULL, From 1e76ce31d72f4b8a64be82d2d6872d2576037dbe Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 3 Oct 2019 19:18:03 +0200 Subject: [PATCH 2/7] Privacy datetimes defaults - PHP changes --- .../components/com_privacy/Table/RequestTable.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_privacy/Table/RequestTable.php b/administrator/components/com_privacy/Table/RequestTable.php index 7b5256b18c222..9f3ccedf30b72 100644 --- a/administrator/components/com_privacy/Table/RequestTable.php +++ b/administrator/components/com_privacy/Table/RequestTable.php @@ -30,6 +30,14 @@ */ class RequestTable extends Table { + /** + * Indicates that columns fully support the NULL value in the database + * + * @var boolean + * @since __DEPLOY_VERSION__ + */ + protected $_supportNullValue = true; + /** * The class constructor. * @@ -51,7 +59,7 @@ public function __construct(DatabaseDriver $db) * * @since 3.9.0 */ - public function store($updateNulls = false) + public function store($updateNulls = true) { $date = Factory::getDate(); From eb5a78c6ad52986ffef0102c80bf726e593e3c8a Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 3 Oct 2019 19:24:04 +0200 Subject: [PATCH 3/7] Revert "Privacy datetimes defaults - PHP changes" This reverts commit 1e76ce31d72f4b8a64be82d2d6872d2576037dbe. --- .../components/com_privacy/Table/RequestTable.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/administrator/components/com_privacy/Table/RequestTable.php b/administrator/components/com_privacy/Table/RequestTable.php index 9f3ccedf30b72..7b5256b18c222 100644 --- a/administrator/components/com_privacy/Table/RequestTable.php +++ b/administrator/components/com_privacy/Table/RequestTable.php @@ -30,14 +30,6 @@ */ class RequestTable extends Table { - /** - * Indicates that columns fully support the NULL value in the database - * - * @var boolean - * @since __DEPLOY_VERSION__ - */ - protected $_supportNullValue = true; - /** * The class constructor. * @@ -59,7 +51,7 @@ public function __construct(DatabaseDriver $db) * * @since 3.9.0 */ - public function store($updateNulls = true) + public function store($updateNulls = false) { $date = Factory::getDate(); From 6d39c829d1eaf5a639f5311931d211e6ff73f88d Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 3 Oct 2019 19:28:22 +0200 Subject: [PATCH 4/7] Change confirm_token_created_at to not nullable --- .../com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql | 2 +- .../com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql | 1 - administrator/components/com_privacy/Table/RequestTable.php | 5 +++++ installation/sql/mysql/joomla.sql | 2 +- installation/sql/postgresql/joomla.sql | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql index 8e7cb083fdb22..72df078b2c3bb 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql @@ -1,4 +1,4 @@ ALTER TABLE `#__privacy_requests` MODIFY `requested_at` datetime NOT NULL; -ALTER TABLE `#__privacy_requests` MODIFY `confirm_token_created_at` datetime NULL DEFAULT NULL; +ALTER TABLE `#__privacy_requests` MODIFY `confirm_token_created_at` datetime NOT NULL; ALTER TABLE `#__privacy_consents` MODIFY `created` datetime NOT NULL; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql index 97ba1ba3a5995..7b9fc314c9dfd 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql @@ -1,5 +1,4 @@ ALTER TABLE "#__privacy_requests" ALTER COLUMN "requested_at" DROP DEFAULT; -ALTER TABLE "#__privacy_requests" ALTER COLUMN "confirm_token_created_at" DROP NOT NULL; ALTER TABLE "#__privacy_requests" ALTER COLUMN "confirm_token_created_at" DROP DEFAULT; ALTER TABLE "#__privacy_consents" ALTER COLUMN "created" DROP DEFAULT; diff --git a/administrator/components/com_privacy/Table/RequestTable.php b/administrator/components/com_privacy/Table/RequestTable.php index 7b5256b18c222..692af2aa7d516 100644 --- a/administrator/components/com_privacy/Table/RequestTable.php +++ b/administrator/components/com_privacy/Table/RequestTable.php @@ -67,6 +67,11 @@ public function store($updateNulls = false) { $this->requested_at = $date->toSql(); } + + if (!$this->confirm_token_created_at) + { + $this->confirm_token_created_at = $date->toSql(); + } } return parent::store($updateNulls); diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index af1661f583c0f..6d3063d9f338e 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -1655,7 +1655,7 @@ CREATE TABLE IF NOT EXISTS `#__privacy_requests` ( `status` tinyint(4) NOT NULL DEFAULT 0, `request_type` varchar(25) NOT NULL DEFAULT '', `confirm_token` varchar(100) NOT NULL DEFAULT '', - `confirm_token_created_at` datetime, + `confirm_token_created_at` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index beb11bfadaa0f..cbbe81adbdf3d 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -1660,7 +1660,7 @@ CREATE TABLE "#__privacy_requests" ( "status" smallint DEFAULT 0 NOT NULL, "request_type" varchar(25) DEFAULT '' NOT NULL, "confirm_token" varchar(100) DEFAULT '' NOT NULL, - "confirm_token_created_at" timestamp without time zone, + "confirm_token_created_at" timestamp without time zone NOT NULL, PRIMARY KEY ("id") ); From 67a513925467dd3976e6d984cc9d19ab3cda0d26 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 3 Oct 2019 19:42:28 +0200 Subject: [PATCH 5/7] Update old records --- .../com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql | 2 ++ .../com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql | 3 +++ 2 files changed, 5 insertions(+) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql index 72df078b2c3bb..80fcfacc284d2 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-26.sql @@ -2,3 +2,5 @@ ALTER TABLE `#__privacy_requests` MODIFY `requested_at` datetime NOT NULL; ALTER TABLE `#__privacy_requests` MODIFY `confirm_token_created_at` datetime NOT NULL; ALTER TABLE `#__privacy_consents` MODIFY `created` datetime NOT NULL; + +UPDATE `#__privacy_requests` SET `confirm_token_created_at` = `requested_at` WHERE `confirm_token_created_at` = '0000-00-00 00:00:00'; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql index 7b9fc314c9dfd..35a9de61feb37 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql @@ -2,3 +2,6 @@ ALTER TABLE "#__privacy_requests" ALTER COLUMN "requested_at" DROP DEFAULT; ALTER TABLE "#__privacy_requests" ALTER COLUMN "confirm_token_created_at" DROP DEFAULT; ALTER TABLE "#__privacy_consents" ALTER COLUMN "created" DROP DEFAULT; + +UPDATE "#__privacy_requests" SET "confirm_token_created_at" = "requested_at" WHERE "confirm_token_created_at" = '0000-00-00 00:00:00'; + From ab460449511b8cfff23f4cdc25a1cd3fd28db0d3 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 3 Oct 2019 19:43:20 +0200 Subject: [PATCH 6/7] Correct postgresql, silly me --- .../com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql index 35a9de61feb37..dbbfdb04f63f5 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql @@ -3,5 +3,5 @@ ALTER TABLE "#__privacy_requests" ALTER COLUMN "confirm_token_created_at" DROP D ALTER TABLE "#__privacy_consents" ALTER COLUMN "created" DROP DEFAULT; -UPDATE "#__privacy_requests" SET "confirm_token_created_at" = "requested_at" WHERE "confirm_token_created_at" = '0000-00-00 00:00:00'; +UPDATE "#__privacy_requests" SET "confirm_token_created_at" = "requested_at" WHERE "confirm_token_created_at" = '1970-01-01 00:00:00'; From cfbc030a678dabf8f38cde60929280891d9e93da Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 3 Oct 2019 22:13:59 +0200 Subject: [PATCH 7/7] Remove empty line in postgresql/4.0.0-2019-09-26.sql Co-Authored-By: Quy --- .../com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql index dbbfdb04f63f5..3e4c75c183667 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-26.sql @@ -4,4 +4,3 @@ ALTER TABLE "#__privacy_requests" ALTER COLUMN "confirm_token_created_at" DROP D ALTER TABLE "#__privacy_consents" ALTER COLUMN "created" DROP DEFAULT; UPDATE "#__privacy_requests" SET "confirm_token_created_at" = "requested_at" WHERE "confirm_token_created_at" = '1970-01-01 00:00:00'; -