diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-08-01.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-08-01.sql new file mode 100644 index 0000000000000..72a50731c9444 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-08-01.sql @@ -0,0 +1,8 @@ +ALTER TABLE `#__ucm_content` MODIFY `core_created_time` datetime NOT NULL; +ALTER TABLE `#__ucm_content` MODIFY `core_modified_time` datetime NOT NULL; + +ALTER TABLE `#__ucm_content` MODIFY `core_publish_up` datetime NULL DEFAULT NULL; +ALTER TABLE `#__ucm_content` MODIFY `core_publish_down` datetime NULL DEFAULT NULL; +ALTER TABLE `#__ucm_content` MODIFY `core_checked_out_time` datetime NULL DEFAULT NULL; + +ALTER TABLE `#__ucm_history` MODIFY `save_date` datetime NOT NULL; diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-14.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-14.sql index eec96a1aa255d..655d9ac166366 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-14.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-14.sql @@ -1,7 +1,26 @@ +ALTER TABLE `#__content` MODIFY `created` datetime NOT NULL; +ALTER TABLE `#__content` MODIFY `modified` datetime NOT NULL; + ALTER TABLE `#__content` MODIFY `publish_up` datetime NULL DEFAULT NULL; ALTER TABLE `#__content` MODIFY `publish_down` datetime NULL DEFAULT NULL; ALTER TABLE `#__content` MODIFY `checked_out_time` datetime NULL DEFAULT NULL; +UPDATE `#__content` SET `modified` = `created` WHERE `modified` = '0000-00-00 00:00:00'; + UPDATE `#__content` SET `publish_up` = NULL WHERE `publish_up` = '0000-00-00 00:00:00'; UPDATE `#__content` SET `publish_down` = NULL WHERE `publish_down` = '0000-00-00 00:00:00'; UPDATE `#__content` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00'; + +UPDATE `#__ucm_content` SET `core_modified_time` = `core_created_time` + WHERE `core_type_alias` = 'com_content.article' + AND `core_modified_time` = '0000-00-00 00:00:00'; + +UPDATE `#__ucm_content` SET `core_publish_up` = NULL + WHERE `core_type_alias` = 'com_content.article' + AND `core_publish_up` = '0000-00-00 00:00:00'; +UPDATE `#__ucm_content` SET `core_publish_down` = NULL + WHERE `core_type_alias` = 'com_content.article' + AND `core_publish_down` = '0000-00-00 00:00:00'; +UPDATE `#__ucm_content` SET `core_checked_out_time` = NULL + WHERE `core_type_alias` = 'com_content.article' + AND `core_checked_out_time` = '0000-00-00 00:00:00'; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-08-01.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-08-01.sql new file mode 100644 index 0000000000000..e0958379aa79f --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-08-01.sql @@ -0,0 +1,14 @@ +ALTER TABLE "#__ucm_content" ALTER COLUMN "core_created_time" DROP DEFAULT; + +ALTER TABLE "#__ucm_content" ALTER COLUMN "core_modified_time" DROP DEFAULT; + +ALTER TABLE "#__ucm_content" ALTER COLUMN "core_publish_up" DROP NOT NULL; +ALTER TABLE "#__ucm_content" ALTER COLUMN "core_publish_up" DROP DEFAULT; + +ALTER TABLE "#__ucm_content" ALTER COLUMN "core_publish_down" DROP NOT NULL; +ALTER TABLE "#__ucm_content" ALTER COLUMN "core_publish_down" DROP DEFAULT; + +ALTER TABLE "#__ucm_content" ALTER COLUMN "core_checked_out_time" DROP NOT NULL; +ALTER TABLE "#__ucm_content" ALTER COLUMN "core_checked_out_time" DROP DEFAULT; + +ALTER TABLE "#__ucm_history" ALTER COLUMN "save_date" DROP DEFAULT; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-14.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-14.sql index 8ae870d3d45b8..252696d2d5b11 100644 --- a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-14.sql +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-14.sql @@ -1,3 +1,7 @@ +ALTER TABLE "#__content" ALTER COLUMN "created" DROP DEFAULT; + +ALTER TABLE "#__content" ALTER COLUMN "modified" DROP DEFAULT; + ALTER TABLE "#__content" ALTER COLUMN "publish_up" DROP NOT NULL; ALTER TABLE "#__content" ALTER COLUMN "publish_up" DROP DEFAULT; @@ -10,3 +14,13 @@ ALTER TABLE "#__content" ALTER COLUMN "checked_out_time" DROP DEFAULT; UPDATE "#__content" SET "publish_up" = NULL WHERE "publish_up" = '1970-01-01 00:00:00'; UPDATE "#__content" SET "publish_down" = NULL WHERE "publish_down" = '1970-01-01 00:00:00'; UPDATE "#__content" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00'; + +UPDATE "#__ucm_content" SET "core_publish_up" = NULL + WHERE "core_type_alias" = 'com_content.article' + AND "core_publish_up" = '1970-01-01 00:00:00'; +UPDATE "#__ucm_content" SET "core_publish_down" = NULL + WHERE "core_type_alias" = 'com_content.article' + AND "core_publish_down" = '1970-01-01 00:00:00'; +UPDATE "#__ucm_content" SET "core_checked_out_time" = NULL + WHERE "core_type_alias" = 'com_content.article' + AND "core_checked_out_time" = '1970-01-01 00:00:00'; diff --git a/components/com_content/Model/ArticleModel.php b/components/com_content/Model/ArticleModel.php index a72a9184bad30..7dbbe71b47244 100644 --- a/components/com_content/Model/ArticleModel.php +++ b/components/com_content/Model/ArticleModel.php @@ -100,9 +100,7 @@ public function getItem($pk = null) $this->getState( 'item.select', 'a.id, a.asset_id, a.title, a.alias, a.introtext, a.fulltext, ' . 'a.state, a.catid, a.created, a.created_by, a.created_by_alias, ' . - // Use created if modified is 0 - 'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' . - 'a.modified_by, a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, ' . + 'a.modified, a.modified_by, a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, ' . 'a.images, a.urls, a.attribs, a.version, a.ordering, ' . 'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language' ) diff --git a/components/com_content/Model/ArticlesModel.php b/components/com_content/Model/ArticlesModel.php index 9379256aa9939..2bcbff921d563 100644 --- a/components/com_content/Model/ArticlesModel.php +++ b/components/com_content/Model/ArticlesModel.php @@ -207,9 +207,7 @@ protected function getListQuery() // If category is not published then force 0 'CASE WHEN c.published = 2 AND ws.condition > 0 THEN ' . (int) ContentComponent::CONDITION_ARCHIVED . ' WHEN c.published != 1 THEN ' . (int) ContentComponent::CONDITION_UNPUBLISHED . ' ELSE ws.condition END as state,' . - // Use created if modified is 0 - 'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' . - 'a.modified_by, uam.name as modified_by_name,' . + 'a.modified, a.modified_by, uam.name as modified_by_name,' . // Use created if publish_up is 0 'CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END as publish_up,' . 'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' . @@ -467,7 +465,6 @@ function ($data) use ($db) } // Define null and now dates - $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote(Factory::getDate()->toSql()); // Filter by start and end dates. @@ -484,8 +481,8 @@ function ($data) use ($db) switch ($dateFiltering) { case 'range': - $startDateRange = $db->quote($this->getState('filter.start_date_range', $nullDate)); - $endDateRange = $db->quote($this->getState('filter.end_date_range', $nullDate)); + $startDateRange = $db->quote($this->getState('filter.start_date_range')); + $endDateRange = $db->quote($this->getState('filter.end_date_range')); $query->where( '(' . $dateField . ' >= ' . $startDateRange . ' AND ' . $dateField . ' <= ' . $endDateRange . ')' diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 490e66cead243..c0ad46e8a378f 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -346,10 +346,10 @@ CREATE TABLE IF NOT EXISTS `#__content` ( `fulltext` mediumtext NOT NULL, `state` tinyint(3) NOT NULL DEFAULT 0, `catid` int(10) unsigned NOT NULL DEFAULT 0, - `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `created` datetime NOT NULL, `created_by` int(10) unsigned NOT NULL DEFAULT 0, `created_by_alias` varchar(255) NOT NULL DEFAULT '', - `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` datetime NOT NULL, `modified_by` int(10) unsigned NOT NULL DEFAULT 0, `checked_out` int(10) unsigned NOT NULL DEFAULT 0, `checked_out_time` datetime NULL DEFAULT NULL, @@ -1863,7 +1863,7 @@ CREATE TABLE IF NOT EXISTS `#__ucm_content` ( `core_alias` varchar(400) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '', `core_body` mediumtext NOT NULL DEFAULT '', `core_state` tinyint(1) NOT NULL DEFAULT 0, - `core_checked_out_time` varchar(255) NOT NULL DEFAULT '0000-00-00 00:00:00', + `core_checked_out_time` datetime, `core_checked_out_user_id` int(10) unsigned NOT NULL DEFAULT 0, `core_access` int(10) unsigned NOT NULL DEFAULT 0, `core_params` text NOT NULL DEFAULT '', @@ -1871,12 +1871,12 @@ CREATE TABLE IF NOT EXISTS `#__ucm_content` ( `core_metadata` varchar(2048) NOT NULL DEFAULT '' COMMENT 'JSON encoded metadata properties.', `core_created_user_id` int(10) unsigned NOT NULL DEFAULT 0, `core_created_by_alias` varchar(255) NOT NULL DEFAULT '', - `core_created_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `core_created_time` datetime NOT NULL, `core_modified_user_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Most recent user that modified', - `core_modified_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `core_modified_time` datetime NOT NULL, `core_language` char(7) NOT NULL DEFAULT '', - `core_publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `core_publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `core_publish_up` datetime, + `core_publish_down` datetime, `core_content_item_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'ID from the individual type table', `asset_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', `core_images` text NOT NULL DEFAULT '', @@ -1914,7 +1914,7 @@ CREATE TABLE IF NOT EXISTS `#__ucm_history` ( `ucm_item_id` int(10) unsigned NOT NULL, `ucm_type_id` int(10) unsigned NOT NULL, `version_note` varchar(255) NOT NULL DEFAULT '' COMMENT 'Optional version name', - `save_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `save_date` datetime NOT NULL, `editor_user_id` int(10) unsigned NOT NULL DEFAULT 0, `character_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'Number of characters in this version.', `sha1_hash` varchar(50) NOT NULL DEFAULT '' COMMENT 'SHA1 hash of the version_data column.', diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index fc8b2e60d1a1e..1e1c60f061970 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -351,10 +351,10 @@ CREATE TABLE IF NOT EXISTS "#__content" ( "fulltext" text NOT NULL, "state" smallint DEFAULT 0 NOT NULL, "catid" bigint DEFAULT 0 NOT NULL, - "created" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "created" timestamp without time zone NOT NULL, "created_by" bigint DEFAULT 0 NOT NULL, "created_by_alias" varchar(255) DEFAULT '' NOT NULL, - "modified" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "modified" timestamp without time zone NOT NULL, "modified_by" bigint DEFAULT 0 NOT NULL, "checked_out" bigint DEFAULT 0 NOT NULL, "checked_out_time" timestamp without time zone, @@ -1855,7 +1855,7 @@ CREATE TABLE IF NOT EXISTS "#__ucm_content" ( "core_alias" varchar(255) DEFAULT '' NOT NULL, "core_body" text NOT NULL DEFAULT '', "core_state" smallint DEFAULT 0 NOT NULL, - "core_checked_out_time" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "core_checked_out_time" timestamp without time zone, "core_checked_out_user_id" bigint DEFAULT 0 NOT NULL, "core_access" bigint DEFAULT 0 NOT NULL, "core_params" text DEFAULT '' NOT NULL, @@ -1863,12 +1863,12 @@ CREATE TABLE IF NOT EXISTS "#__ucm_content" ( "core_metadata" text DEFAULT '' NOT NULL, "core_created_user_id" bigint DEFAULT 0 NOT NULL, "core_created_by_alias" varchar(255) DEFAULT '' NOT NULL, - "core_created_time" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "core_created_time" timestamp without time zone NOT NULL, "core_modified_user_id" bigint DEFAULT 0 NOT NULL, - "core_modified_time" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "core_modified_time" timestamp without time zone NOT NULL, "core_language" varchar(7) DEFAULT '' NOT NULL, - "core_publish_up" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, - "core_publish_down" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "core_publish_up" timestamp without time zone, + "core_publish_down" timestamp without time zone, "core_content_item_id" bigint DEFAULT 0 NOT NULL, "asset_id" bigint DEFAULT 0 NOT NULL, "core_images" text DEFAULT '' NOT NULL, @@ -1905,7 +1905,7 @@ CREATE TABLE IF NOT EXISTS "#__ucm_history" ( "ucm_item_id" integer NOT NULL, "ucm_type_id" integer NOT NULL, "version_note" varchar(255) NOT NULL DEFAULT '', - "save_date" timestamp with time zone NOT NULL DEFAULT '1970-01-01 00:00:00', + "save_date" timestamp with time zone NOT NULL, "editor_user_id" integer NOT NULL DEFAULT 0, "character_count" integer NOT NULL DEFAULT 0, "sha1_hash" varchar(50) NOT NULL DEFAULT '', diff --git a/libraries/src/Table/CoreContent.php b/libraries/src/Table/CoreContent.php index 37ac1628e726a..1ab00c70c212f 100644 --- a/libraries/src/Table/CoreContent.php +++ b/libraries/src/Table/CoreContent.php @@ -26,6 +26,14 @@ */ class CoreContent extends Table { + /** + * Indicates that columns fully support the NULL value in the database + * + * @var boolean + * @since __DEPLOY_VERSION__ + */ + protected $_supportNullValue = true; + /** * Constructor * @@ -245,7 +253,7 @@ public function deleteByContentId($contentItemId = null, $typeAlias = null) * * @since 3.1 */ - public function store($updateNulls = false) + public function store($updateNulls = true) { $date = Factory::getDate(); $user = Factory::getUser(); @@ -271,6 +279,11 @@ public function store($updateNulls = false) $this->core_created_user_id = $user->get('id'); } + if (!(int) $this->core_modified_time) + { + $this->core_modified_time = $this->core_created_time; + } + $isNew = true; } @@ -296,7 +309,7 @@ public function store($updateNulls = false) * * @since 3.1 */ - protected function storeUcmBase($updateNulls = false, $isNew = false) + protected function storeUcmBase($updateNulls = true, $isNew = false) { // Store the ucm_base row $db = $this->getDbo(); diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index 6193f735efeb1..d33adbaf2ab08 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -53,7 +53,6 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) $db = Factory::getDbo(); $user = Factory::getUser(); $lang = Factory::getLanguage(); - $nullDate = $db->getNullDate(); $date = Factory::getDate(); $now = $date->toSql(); @@ -253,7 +252,7 @@ private static function getQueryDate($orderDate) { // Use created if modified is not set case 'modified' : - $queryDate = ' CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END'; + $queryDate = ' a.modified'; break; // Use created if publish_up is not set