From 15b62180473aaae8423bfe71a7f4d89cc0241f04 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 1 Aug 2019 20:15:07 +0200 Subject: [PATCH 1/7] Setting datetime fields to real null value for com_content --- .../sql/updates/mysql/4.0.0-2019-07-31.sql | 10 ++++++++++ .../sql/updates/postgresql/4.0.0-2019-07-31.sql | 13 +++++++++++++ .../com_content/Model/ArticleModel.php | 2 +- .../system/js/fields/calendar.es5.js | 2 +- .../com_content/Helper/AssociationHelper.php | 6 ++---- components/com_content/Helper/QueryHelper.php | 8 +++----- components/com_content/Model/ArchiveModel.php | 5 ++--- components/com_content/Model/ArticleModel.php | 8 +++----- components/com_content/Model/ArticlesModel.php | 8 ++++---- components/com_content/tmpl/article/default.php | 2 +- .../com_content/tmpl/category/blog_item.php | 4 ++-- .../tmpl/category/default_articles.php | 2 +- .../com_content/tmpl/featured/default_item.php | 6 +++--- installation/sql/mysql/joomla.sql | 8 ++++---- installation/sql/postgresql/joomla.sql | 8 ++++---- libraries/src/Form/Field/CalendarField.php | 11 ++++++++--- libraries/src/Table/Content.php | 16 ++++++++++++---- .../Helper/ArticlesLatestHelper.php | 2 +- .../Helper/RelatedItemsHelper.php | 5 ++--- .../content/pagenavigation/pagenavigation.php | 9 ++++----- plugins/sampledata/multilang/multilang.php | 2 +- 21 files changed, 82 insertions(+), 55 deletions(-) create mode 100644 administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql create mode 100644 administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-07-31.sql diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql new file mode 100644 index 000000000000..e9b99248c995 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql @@ -0,0 +1,10 @@ +ALTER TABLE `#__content` + MODIFY `created` DATETIME NULL DEFAULT NULL, + MODIFY `modified` DATETIME NULL DEFAULT NULL, + MODIFY `publish_up` DATETIME NULL DEFAULT NULL, + MODIFY `publish_down` DATETIME NULL DEFAULT NULL; + +UPDATE `#__content` SET `created` = NULL WHERE `created` = '0000-00-00 00:00:00'; +UPDATE `#__content` SET `modified` = NULL 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'; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-07-31.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-07-31.sql new file mode 100644 index 000000000000..d6718d6fb5fe --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-07-31.sql @@ -0,0 +1,13 @@ +ALTER TABLE "#__content" ALTER COLUMN "created" DROP DEFAULT; +ALTER TABLE "#__content" ALTER COLUMN "created" DROP NOT NULL; +ALTER TABLE "#__content" ALTER COLUMN "modified" DROP DEFAULT; +ALTER TABLE "#__content" ALTER COLUMN "modified" DROP NOT NULL; +ALTER TABLE "#__content" ALTER COLUMN "publish_up" DROP DEFAULT; +ALTER TABLE "#__content" ALTER COLUMN "publish_up" DROP NOT NULL; +ALTER TABLE "#__content" ALTER COLUMN "publish_down" DROP DEFAULT; +ALTER TABLE "#__content" ALTER COLUMN "publish_down" DROP NOT NULL; + +UPDATE "#__content" SET "created" = NULL WHERE "created" = '1970-01-01 00:00:00'; +UPDATE "#__content" SET "modified" = NULL WHERE "modified" = '1970-01-01 00:00:00'; +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'; diff --git a/administrator/components/com_content/Model/ArticleModel.php b/administrator/components/com_content/Model/ArticleModel.php index 4a3dc90195c3..404e4749884b 100644 --- a/administrator/components/com_content/Model/ArticleModel.php +++ b/administrator/components/com_content/Model/ArticleModel.php @@ -337,7 +337,7 @@ protected function prepareTable($table) if ($table->state == Workflow::CONDITION_PUBLISHED && intval($table->publish_down) == 0) { - $table->publish_down = $this->getDbo()->getNullDate(); + $table->publish_down = null; } // Increment the content version number. diff --git a/build/media_source/system/js/fields/calendar.es5.js b/build/media_source/system/js/fields/calendar.es5.js index cf29d845621b..1dea98272da0 100644 --- a/build/media_source/system/js/fields/calendar.es5.js +++ b/build/media_source/system/js/fields/calendar.es5.js @@ -778,7 +778,7 @@ break; } } - self.inputField.setAttribute('data-alt-value', "0000-00-00 00:00:00"); + self.inputField.setAttribute('data-alt-value', ""); self.inputField.setAttribute('value', ''); self.inputField.value = ''; }); diff --git a/components/com_content/Helper/AssociationHelper.php b/components/com_content/Helper/AssociationHelper.php index 6a3f6d3d7b96..874a02a17c31 100644 --- a/components/com_content/Helper/AssociationHelper.php +++ b/components/com_content/Helper/AssociationHelper.php @@ -65,13 +65,11 @@ public static function getAssociations($id = 0, $view = null, $layout = null) if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) { // Filter by start and end dates. - $nullDate = $db->quote($db->getNullDate()); $date = Factory::getDate(); - $nowDate = $db->quote($date->toSql()); - $advClause[] = '(c2.publish_up = ' . $nullDate . ' OR c2.publish_up <= ' . $nowDate . ')'; - $advClause[] = '(c2.publish_down = ' . $nullDate . ' OR c2.publish_down >= ' . $nowDate . ')'; + $advClause[] = '(ISNULL(c2.publish_up) OR c2.publish_up <= ' . $nowDate . ')'; + $advClause[] = '(ISNULL(c2.publish_down) OR c2.publish_down >= ' . $nowDate . ')'; // Filter by published $advClause[] = 'c2.state = 1'; diff --git a/components/com_content/Helper/QueryHelper.php b/components/com_content/Helper/QueryHelper.php index 02e7e5a1c3b4..f5e6b18a1f29 100644 --- a/components/com_content/Helper/QueryHelper.php +++ b/components/com_content/Helper/QueryHelper.php @@ -179,21 +179,19 @@ public static function orderbySecondary($orderby, $orderDate = 'created', Databa */ public static function getQueryDate($orderDate, DatabaseInterface $db = null) { - $db = $db ?: Factory::getDbo(); - switch ($orderDate) { case 'modified' : - $queryDate = ' CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END '; break; case 'unpublished' : - $queryDate = ' CASE WHEN a.publish_down = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_down END '; + $queryDate = ' CASE WHEN ISNULL(a.publish_down) THEN a.created ELSE a.publish_down END '; break; case 'created' : default : diff --git a/components/com_content/Model/ArchiveModel.php b/components/com_content/Model/ArchiveModel.php index 4a7e47284886..4899899b6103 100644 --- a/components/com_content/Model/ArchiveModel.php +++ b/components/com_content/Model/ArchiveModel.php @@ -187,7 +187,6 @@ protected function _getList($query, $limitstart=0, $limit=0) public function getYears() { $db = $this->getDbo(); - $nullDate = $db->quote($db->getNullDate()); $nowDate = $db->quote(Factory::getDate()->toSql()); $query = $db->getQuery(true); @@ -199,8 +198,8 @@ public function getYears() ->where($db->quoteName('c.id') . ' = ' . $db->quoteName('wa.item_id')) ->where($db->quoteName('ws.id') . ' = ' . $db->quoteName('wa.stage_id')) ->where($db->quoteName('ws.condition') . '= ' . (int) ContentComponent::CONDITION_ARCHIVED) - ->where('(c.publish_up = ' . $nullDate . ' OR c.publish_up <= ' . $nowDate . ')') - ->where('(c.publish_down = ' . $nullDate . ' OR c.publish_down >= ' . $nowDate . ')') + ->where('(ISNULL(c.publish_up) OR c.publish_up <= ' . $nowDate . ')') + ->where('(ISNULL(c.publish_down) OR c.publish_down >= ' . $nowDate . ')') ->order('1 ASC'); $db->setQuery($query); diff --git a/components/com_content/Model/ArticleModel.php b/components/com_content/Model/ArticleModel.php index 1064ed065920..5dc90fba8a9a 100644 --- a/components/com_content/Model/ArticleModel.php +++ b/components/com_content/Model/ArticleModel.php @@ -101,7 +101,7 @@ public function getItem($pk = null) '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, ' . + 'CASE WHEN ISNULL(a.modified) 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.images, a.urls, a.attribs, a.version, a.ordering, ' . 'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language' @@ -155,13 +155,11 @@ public function getItem($pk = null) ) { // Filter by start and end dates. - $nullDate = $db->quote($db->getNullDate()); $date = Factory::getDate(); - $nowDate = $db->quote($date->toSql()); - $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')') - ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $nowDate . ')') + ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $nowDate . ')'); } // Filter by published state. diff --git a/components/com_content/Model/ArticlesModel.php b/components/com_content/Model/ArticlesModel.php index 21cbe7833dbf..7e348e641d22 100644 --- a/components/com_content/Model/ArticlesModel.php +++ b/components/com_content/Model/ArticlesModel.php @@ -208,10 +208,10 @@ protected function getListQuery() '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, ' . + 'CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, uam.name as modified_by_name,' . // Use created if publish_up is 0 - 'CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END as publish_up,' . + 'CASE WHEN ISNULL(a.publish_up) 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, ' . 'a.hits, a.featured, a.language, ' . $query->length('a.fulltext') . ' AS readmore, a.ordering' ) @@ -473,8 +473,8 @@ function ($data) use ($db) // Filter by start and end dates. if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { - $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')') - ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $nowDate . ')') + ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $nowDate . ')'); } // Filter by Date Range or Relative Date diff --git a/components/com_content/tmpl/article/default.php b/components/com_content/tmpl/article/default.php index 973c7689cc15..c3d82846f4b4 100644 --- a/components/com_content/tmpl/article/default.php +++ b/components/com_content/tmpl/article/default.php @@ -61,7 +61,7 @@ item->publish_up) > strtotime(Factory::getDate())) : ?> - item->publish_down) < strtotime(Factory::getDate())) && $this->item->publish_down != Factory::getDbo()->getNullDate()) : ?> + item->publish_down) < strtotime(Factory::getDate())) && !is_null($this->item->publish_down)) : ?> diff --git a/components/com_content/tmpl/category/blog_item.php b/components/com_content/tmpl/category/blog_item.php index 7ccc0bccd7a6..be55ed008560 100644 --- a/components/com_content/tmpl/category/blog_item.php +++ b/components/com_content/tmpl/category/blog_item.php @@ -30,7 +30,7 @@
item->stage_condition == ContentComponent::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate()) - || ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && $this->item->publish_down != Factory::getDbo()->getNullDate())) : ?> + || ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && !is_null($this->item->publish_down))) : ?>
@@ -86,7 +86,7 @@ item->stage_condition == ContentComponent::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate()) - || ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && $this->item->publish_down != Factory::getDbo()->getNullDate())) : ?> + || ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && !is_null($this->item->publish_down))) : ?>
diff --git a/components/com_content/tmpl/category/default_articles.php b/components/com_content/tmpl/category/default_articles.php index f4fad4158614..4aff63755932 100644 --- a/components/com_content/tmpl/category/default_articles.php +++ b/components/com_content/tmpl/category/default_articles.php @@ -235,7 +235,7 @@ - publish_down) < strtotime(Factory::getDate())) && $article->publish_down != Factory::getDbo()->getNullDate()) : ?> + publish_down) < strtotime(Factory::getDate())) && !is_null($article->publish_down)) : ?> diff --git a/components/com_content/tmpl/featured/default_item.php b/components/com_content/tmpl/featured/default_item.php index 2b8b5426c244..e3c6f0a35095 100644 --- a/components/com_content/tmpl/featured/default_item.php +++ b/components/com_content/tmpl/featured/default_item.php @@ -30,7 +30,7 @@
item->state == Workflow::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate()) - || ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && $this->item->publish_down != Factory::getDbo()->getNullDate())) : ?> + || ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && !is_null($this->item->publish_down))) : ?>
@@ -52,7 +52,7 @@ item->publish_up) > strtotime(Factory::getDate())) : ?> - item->publish_down) < strtotime(Factory::getDate())) && $this->item->publish_down != Factory::getDbo()->getNullDate()) : ?> + item->publish_down) < strtotime(Factory::getDate())) && !is_null($this->item->publish_down)) : ?> @@ -104,7 +104,7 @@ item->state == Workflow::CONDITION_UNPUBLISHED || strtotime($this->item->publish_up) > strtotime(Factory::getDate()) - || ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && $this->item->publish_down != $this->db->getNullDate() )) : ?> + || ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && !is_null($this->item->publish_down))) : ?>
diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 39a9762168fd..78e6466dac4e 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -333,15 +333,15 @@ 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, `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, `modified_by` int(10) unsigned NOT NULL DEFAULT 0, `checked_out` int(10) unsigned NOT NULL DEFAULT 0, `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - `publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `publish_up` datetime, + `publish_down` datetime, `images` text NOT NULL, `urls` text NOT NULL, `attribs` varchar(5120) NOT NULL, diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index e7a80571914b..03a89c02c1e8 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -338,15 +338,15 @@ 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, "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, "modified_by" bigint DEFAULT 0 NOT NULL, "checked_out" bigint DEFAULT 0 NOT NULL, "checked_out_time" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, - "publish_up" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, - "publish_down" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL, + "publish_up" timestamp without time zone, + "publish_down" timestamp without time zone, "images" text NOT NULL, "urls" text NOT NULL, "attribs" varchar(5120) NOT NULL, diff --git a/libraries/src/Form/Field/CalendarField.php b/libraries/src/Form/Field/CalendarField.php index 97293055bc02..8c8c4e79f4cb 100644 --- a/libraries/src/Form/Field/CalendarField.php +++ b/libraries/src/Form/Field/CalendarField.php @@ -225,7 +225,7 @@ protected function getInput() { case 'SERVER_UTC': // Convert a date to UTC based on the server timezone. - if ($this->value && $this->value != Factory::getDbo()->getNullDate()) + if ($this->value && strlen($this->value) && $this->value != Factory::getDbo()->getNullDate()) { // Get a date object based on the correct timezone. $date = Factory::getDate($this->value, 'UTC'); @@ -237,7 +237,7 @@ protected function getInput() break; case 'USER_UTC': // Convert a date to UTC based on the user timezone. - if ($this->value && $this->value != Factory::getDbo()->getNullDate()) + if ($this->value && strlen($this->value) && $this->value != Factory::getDbo()->getNullDate()) { // Get a date object based on the correct timezone. $date = Factory::getDate($this->value, 'UTC'); @@ -250,7 +250,7 @@ protected function getInput() } // Format value when not nulldate ('0000-00-00 00:00:00'), otherwise blank it as it would result in 1970-01-01. - if ($this->value && $this->value != Factory::getDbo()->getNullDate() && strtotime($this->value) !== false) + if ($this->value && strlen($this->value) && $this->value != Factory::getDbo()->getNullDate() && strtotime($this->value) !== false) { $tz = date_default_timezone_get(); date_default_timezone_set('UTC'); @@ -384,6 +384,11 @@ public function filter($value, $group = null, Registry $input = null) break; } + if ($return == '') + { + $return = null; + } + return $return; } } diff --git a/libraries/src/Table/Content.php b/libraries/src/Table/Content.php index e125744cacd0..f81c21146fa3 100644 --- a/libraries/src/Table/Content.php +++ b/libraries/src/Table/Content.php @@ -25,6 +25,14 @@ */ class Content extends Table { + /** + * Indicates that columns fully support the NULL value in the database + * + * @var boolean + * @since 4.0.0 + */ + protected $_supportNullValue = true; + /** * Constructor * @@ -247,17 +255,17 @@ public function check() // Set publish_up to null date if not set if (!$this->publish_up) { - $this->publish_up = $this->_db->getNullDate(); + $this->publish_up = null; } // Set publish_down to null date if not set if (!$this->publish_down) { - $this->publish_down = $this->_db->getNullDate(); + $this->publish_down = null; } // Check the publish down date is not earlier than publish up. - if ($this->publish_down < $this->publish_up && $this->publish_down > $this->_db->getNullDate()) + if (!is_null($this->publish_up) && !is_null($this->publish_up) && $this->publish_up > $this->publish_down) { // Swap the dates. $temp = $this->publish_up; @@ -268,7 +276,7 @@ public function check() // Set modified to null date if not set if (!$this->modified) { - $this->modified = $this->_db->getNullDate(); + $this->modified = null; } // Clean up keywords -- eliminate extra spaces between phrases diff --git a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php index 0ce766f4b5de..552653b0cd01 100644 --- a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php +++ b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php @@ -111,7 +111,7 @@ public static function getList(Registry $params, ArticlesModel $model) // Set ordering $order_map = array( 'm_dsc' => 'a.modified DESC, a.created', - 'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN a.created ELSE a.modified END', + 'mc_dsc' => 'CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up', 'random' => $db->getQuery(true)->rand(), diff --git a/modules/mod_related_items/Helper/RelatedItemsHelper.php b/modules/mod_related_items/Helper/RelatedItemsHelper.php index 7a27320efcd5..7983df8e4dac 100644 --- a/modules/mod_related_items/Helper/RelatedItemsHelper.php +++ b/modules/mod_related_items/Helper/RelatedItemsHelper.php @@ -59,7 +59,6 @@ public static function getList(&$params) $temp = explode(':', $temp); $id = $temp[0]; - $nullDate = $db->getNullDate(); $now = Factory::getDate()->toSql(); $related = []; $query = $db->getQuery(true); @@ -116,8 +115,8 @@ public static function getList(&$params) } $query->where('(' . implode(' OR ', $wheres) . ')') - ->where('(a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ')') - ->where('(a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')'); + ->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $db->quote($now) . ')') + ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $db->quote($now) . ')'); // Filter by language if (Multilanguage::isEnabled()) diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index 11c4524062a0..573dfd78bc4e 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(); @@ -127,8 +126,8 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) } $xwhere = ' AND (ws.condition = 1 OR ws.condition = -2)' - . ' AND (publish_up = ' . $db->quote($nullDate) . ' OR publish_up <= ' . $db->quote($now) . ')' - . ' AND (publish_down = ' . $db->quote($nullDate) . ' OR publish_down >= ' . $db->quote($now) . ')'; + . ' AND (ISNULL(publish_up) OR publish_up <= ' . $db->quote($now) . ')' + . ' AND (ISNULL(publish_down) OR publish_down >= ' . $db->quote($now) . ')'; // Array of articles in same category correctly ordered. $query = $db->getQuery(true); @@ -253,12 +252,12 @@ 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 = ' CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END '; break; // Use created as default diff --git a/plugins/sampledata/multilang/multilang.php b/plugins/sampledata/multilang/multilang.php index 11416a25f2bb..a580a1101d37 100644 --- a/plugins/sampledata/multilang/multilang.php +++ b/plugins/sampledata/multilang/multilang.php @@ -1059,7 +1059,7 @@ private function addArticle($itemLanguage, $categoryId) 'created_by' => (int) $this->getAdminId(), 'created_by_alias' => 'Joomla', 'publish_up' => $currentDate, - 'publish_down' => $db->getNullDate(), + 'publish_down' => null, 'version' => 1, 'catid' => $categoryId, 'metadata' => '{"robots":"","author":"","rights":"","tags":null}', From e4805965446ba44f1278408fb046a6baef986fee Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 1 Aug 2019 22:15:45 +0200 Subject: [PATCH 2/7] One alter table for each column for db fixer --- .../com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql index e9b99248c995..4ecfda9b8027 100644 --- a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-07-31.sql @@ -1,8 +1,7 @@ -ALTER TABLE `#__content` - MODIFY `created` DATETIME NULL DEFAULT NULL, - MODIFY `modified` DATETIME NULL DEFAULT NULL, - MODIFY `publish_up` DATETIME NULL DEFAULT NULL, - MODIFY `publish_down` DATETIME NULL DEFAULT NULL; +ALTER TABLE `#__content` MODIFY `created` DATETIME NULL DEFAULT NULL; +ALTER TABLE `#__content` MODIFY `modified` DATETIME NULL DEFAULT NULL; +ALTER TABLE `#__content` MODIFY `publish_up` DATETIME NULL DEFAULT NULL; +ALTER TABLE `#__content` MODIFY `publish_down` DATETIME NULL DEFAULT NULL; UPDATE `#__content` SET `created` = NULL WHERE `created` = '0000-00-00 00:00:00'; UPDATE `#__content` SET `modified` = NULL WHERE `modified` = '0000-00-00 00:00:00'; From 0dab89980ba72dec183d9cc4816748614a39c328 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 1 Aug 2019 22:40:08 +0200 Subject: [PATCH 3/7] There is no isnull function in pgsql --- components/com_content/Helper/AssociationHelper.php | 4 ++-- components/com_content/Helper/QueryHelper.php | 6 +++--- components/com_content/Model/ArchiveModel.php | 4 ++-- components/com_content/Model/ArticleModel.php | 6 +++--- components/com_content/Model/ArticlesModel.php | 8 ++++---- .../mod_articles_latest/Helper/ArticlesLatestHelper.php | 2 +- modules/mod_related_items/Helper/RelatedItemsHelper.php | 4 ++-- plugins/content/pagenavigation/pagenavigation.php | 8 ++++---- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/components/com_content/Helper/AssociationHelper.php b/components/com_content/Helper/AssociationHelper.php index 874a02a17c31..2878857eb439 100644 --- a/components/com_content/Helper/AssociationHelper.php +++ b/components/com_content/Helper/AssociationHelper.php @@ -68,8 +68,8 @@ public static function getAssociations($id = 0, $view = null, $layout = null) $date = Factory::getDate(); $nowDate = $db->quote($date->toSql()); - $advClause[] = '(ISNULL(c2.publish_up) OR c2.publish_up <= ' . $nowDate . ')'; - $advClause[] = '(ISNULL(c2.publish_down) OR c2.publish_down >= ' . $nowDate . ')'; + $advClause[] = '(c2.publish_up IS NULL OR c2.publish_up <= ' . $nowDate . ')'; + $advClause[] = '(c2.publish_down IS NULL OR c2.publish_down >= ' . $nowDate . ')'; // Filter by published $advClause[] = 'c2.state = 1'; diff --git a/components/com_content/Helper/QueryHelper.php b/components/com_content/Helper/QueryHelper.php index f5e6b18a1f29..3e524f78658a 100644 --- a/components/com_content/Helper/QueryHelper.php +++ b/components/com_content/Helper/QueryHelper.php @@ -182,16 +182,16 @@ public static function getQueryDate($orderDate, DatabaseInterface $db = null) switch ($orderDate) { case 'modified' : - $queryDate = ' CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN a.modified IS NULL THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END '; break; case 'unpublished' : - $queryDate = ' CASE WHEN ISNULL(a.publish_down) THEN a.created ELSE a.publish_down END '; + $queryDate = ' CASE WHEN a.publish_down IS NULL THEN a.created ELSE a.publish_down END '; break; case 'created' : default : diff --git a/components/com_content/Model/ArchiveModel.php b/components/com_content/Model/ArchiveModel.php index 4899899b6103..1b15b9114d85 100644 --- a/components/com_content/Model/ArchiveModel.php +++ b/components/com_content/Model/ArchiveModel.php @@ -198,8 +198,8 @@ public function getYears() ->where($db->quoteName('c.id') . ' = ' . $db->quoteName('wa.item_id')) ->where($db->quoteName('ws.id') . ' = ' . $db->quoteName('wa.stage_id')) ->where($db->quoteName('ws.condition') . '= ' . (int) ContentComponent::CONDITION_ARCHIVED) - ->where('(ISNULL(c.publish_up) OR c.publish_up <= ' . $nowDate . ')') - ->where('(ISNULL(c.publish_down) OR c.publish_down >= ' . $nowDate . ')') + ->where('(c.publish_up IS NULL OR c.publish_up <= ' . $nowDate . ')') + ->where('(c.publish_down IS NULL OR c.publish_down >= ' . $nowDate . ')') ->order('1 ASC'); $db->setQuery($query); diff --git a/components/com_content/Model/ArticleModel.php b/components/com_content/Model/ArticleModel.php index 5dc90fba8a9a..f30a3a8f0197 100644 --- a/components/com_content/Model/ArticleModel.php +++ b/components/com_content/Model/ArticleModel.php @@ -101,7 +101,7 @@ public function getItem($pk = null) '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 ISNULL(a.modified) THEN a.created ELSE a.modified END as modified, ' . + 'CASE WHEN a.modified IS NULL 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.images, a.urls, a.attribs, a.version, a.ordering, ' . 'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language' @@ -158,8 +158,8 @@ public function getItem($pk = null) $date = Factory::getDate(); $nowDate = $db->quote($date->toSql()); - $query->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $nowDate . ')') - ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(a.publish_up IS NULL OR a.publish_up <= ' . $nowDate . ')') + ->where('(a.publish_down IS NULL OR a.publish_down >= ' . $nowDate . ')'); } // Filter by published state. diff --git a/components/com_content/Model/ArticlesModel.php b/components/com_content/Model/ArticlesModel.php index 7e348e641d22..5cca310bb330 100644 --- a/components/com_content/Model/ArticlesModel.php +++ b/components/com_content/Model/ArticlesModel.php @@ -208,10 +208,10 @@ protected function getListQuery() '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 ISNULL(a.modified) THEN a.created ELSE a.modified END as modified, ' . + 'CASE WHEN a.modified IS NULL THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, uam.name as modified_by_name,' . // Use created if publish_up is 0 - 'CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END as publish_up,' . + '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, ' . 'a.hits, a.featured, a.language, ' . $query->length('a.fulltext') . ' AS readmore, a.ordering' ) @@ -473,8 +473,8 @@ function ($data) use ($db) // Filter by start and end dates. if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { - $query->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $nowDate . ')') - ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(a.publish_up IS NULL OR a.publish_up <= ' . $nowDate . ')') + ->where('(a.publish_down IS NULL OR a.publish_down >= ' . $nowDate . ')'); } // Filter by Date Range or Relative Date diff --git a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php index 552653b0cd01..87619bbf8c23 100644 --- a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php +++ b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php @@ -111,7 +111,7 @@ public static function getList(Registry $params, ArticlesModel $model) // Set ordering $order_map = array( 'm_dsc' => 'a.modified DESC, a.created', - 'mc_dsc' => 'CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END', + 'mc_dsc' => 'CASE WHEN a.modified IS NULL THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up', 'random' => $db->getQuery(true)->rand(), diff --git a/modules/mod_related_items/Helper/RelatedItemsHelper.php b/modules/mod_related_items/Helper/RelatedItemsHelper.php index 7983df8e4dac..57e8f3ef513d 100644 --- a/modules/mod_related_items/Helper/RelatedItemsHelper.php +++ b/modules/mod_related_items/Helper/RelatedItemsHelper.php @@ -115,8 +115,8 @@ public static function getList(&$params) } $query->where('(' . implode(' OR ', $wheres) . ')') - ->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $db->quote($now) . ')') - ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $db->quote($now) . ')'); + ->where('(a.publish_up IS NULL OR a.publish_up <= ' . $db->quote($now) . ')') + ->where('(a.publish_down IS NULL OR a.publish_down >= ' . $db->quote($now) . ')'); // Filter by language if (Multilanguage::isEnabled()) diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index 573dfd78bc4e..5e420349ec87 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -126,8 +126,8 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) } $xwhere = ' AND (ws.condition = 1 OR ws.condition = -2)' - . ' AND (ISNULL(publish_up) OR publish_up <= ' . $db->quote($now) . ')' - . ' AND (ISNULL(publish_down) OR publish_down >= ' . $db->quote($now) . ')'; + . ' AND (publish_up IS NULL OR publish_up <= ' . $db->quote($now) . ')' + . ' AND (publish_down IS NULL OR publish_down >= ' . $db->quote($now) . ')'; // Array of articles in same category correctly ordered. $query = $db->getQuery(true); @@ -252,12 +252,12 @@ private static function getQueryDate($orderDate) { // Use created if modified is not set case 'modified' : - $queryDate = ' CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN a.modified IS NULL THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END '; break; // Use created as default From 13bda81501e537d534c0d7ba39ebecc213ed0891 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Thu, 1 Aug 2019 23:08:59 +0200 Subject: [PATCH 4/7] Revert "There is no isnull function in pgsql" This reverts commit 0dab89980ba72dec183d9cc4816748614a39c328. --- components/com_content/Helper/AssociationHelper.php | 4 ++-- components/com_content/Helper/QueryHelper.php | 6 +++--- components/com_content/Model/ArchiveModel.php | 4 ++-- components/com_content/Model/ArticleModel.php | 6 +++--- components/com_content/Model/ArticlesModel.php | 8 ++++---- .../mod_articles_latest/Helper/ArticlesLatestHelper.php | 2 +- modules/mod_related_items/Helper/RelatedItemsHelper.php | 4 ++-- plugins/content/pagenavigation/pagenavigation.php | 8 ++++---- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/components/com_content/Helper/AssociationHelper.php b/components/com_content/Helper/AssociationHelper.php index 2878857eb439..874a02a17c31 100644 --- a/components/com_content/Helper/AssociationHelper.php +++ b/components/com_content/Helper/AssociationHelper.php @@ -68,8 +68,8 @@ public static function getAssociations($id = 0, $view = null, $layout = null) $date = Factory::getDate(); $nowDate = $db->quote($date->toSql()); - $advClause[] = '(c2.publish_up IS NULL OR c2.publish_up <= ' . $nowDate . ')'; - $advClause[] = '(c2.publish_down IS NULL OR c2.publish_down >= ' . $nowDate . ')'; + $advClause[] = '(ISNULL(c2.publish_up) OR c2.publish_up <= ' . $nowDate . ')'; + $advClause[] = '(ISNULL(c2.publish_down) OR c2.publish_down >= ' . $nowDate . ')'; // Filter by published $advClause[] = 'c2.state = 1'; diff --git a/components/com_content/Helper/QueryHelper.php b/components/com_content/Helper/QueryHelper.php index 3e524f78658a..f5e6b18a1f29 100644 --- a/components/com_content/Helper/QueryHelper.php +++ b/components/com_content/Helper/QueryHelper.php @@ -182,16 +182,16 @@ public static function getQueryDate($orderDate, DatabaseInterface $db = null) switch ($orderDate) { case 'modified' : - $queryDate = ' CASE WHEN a.modified IS NULL THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END '; break; case 'unpublished' : - $queryDate = ' CASE WHEN a.publish_down IS NULL THEN a.created ELSE a.publish_down END '; + $queryDate = ' CASE WHEN ISNULL(a.publish_down) THEN a.created ELSE a.publish_down END '; break; case 'created' : default : diff --git a/components/com_content/Model/ArchiveModel.php b/components/com_content/Model/ArchiveModel.php index 1b15b9114d85..4899899b6103 100644 --- a/components/com_content/Model/ArchiveModel.php +++ b/components/com_content/Model/ArchiveModel.php @@ -198,8 +198,8 @@ public function getYears() ->where($db->quoteName('c.id') . ' = ' . $db->quoteName('wa.item_id')) ->where($db->quoteName('ws.id') . ' = ' . $db->quoteName('wa.stage_id')) ->where($db->quoteName('ws.condition') . '= ' . (int) ContentComponent::CONDITION_ARCHIVED) - ->where('(c.publish_up IS NULL OR c.publish_up <= ' . $nowDate . ')') - ->where('(c.publish_down IS NULL OR c.publish_down >= ' . $nowDate . ')') + ->where('(ISNULL(c.publish_up) OR c.publish_up <= ' . $nowDate . ')') + ->where('(ISNULL(c.publish_down) OR c.publish_down >= ' . $nowDate . ')') ->order('1 ASC'); $db->setQuery($query); diff --git a/components/com_content/Model/ArticleModel.php b/components/com_content/Model/ArticleModel.php index f30a3a8f0197..5dc90fba8a9a 100644 --- a/components/com_content/Model/ArticleModel.php +++ b/components/com_content/Model/ArticleModel.php @@ -101,7 +101,7 @@ public function getItem($pk = null) '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 IS NULL THEN a.created ELSE a.modified END as modified, ' . + 'CASE WHEN ISNULL(a.modified) 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.images, a.urls, a.attribs, a.version, a.ordering, ' . 'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language' @@ -158,8 +158,8 @@ public function getItem($pk = null) $date = Factory::getDate(); $nowDate = $db->quote($date->toSql()); - $query->where('(a.publish_up IS NULL OR a.publish_up <= ' . $nowDate . ')') - ->where('(a.publish_down IS NULL OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $nowDate . ')') + ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $nowDate . ')'); } // Filter by published state. diff --git a/components/com_content/Model/ArticlesModel.php b/components/com_content/Model/ArticlesModel.php index 5cca310bb330..7e348e641d22 100644 --- a/components/com_content/Model/ArticlesModel.php +++ b/components/com_content/Model/ArticlesModel.php @@ -208,10 +208,10 @@ protected function getListQuery() '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 IS NULL THEN a.created ELSE a.modified END as modified, ' . + 'CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END as 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,' . + 'CASE WHEN ISNULL(a.publish_up) 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, ' . 'a.hits, a.featured, a.language, ' . $query->length('a.fulltext') . ' AS readmore, a.ordering' ) @@ -473,8 +473,8 @@ function ($data) use ($db) // Filter by start and end dates. if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { - $query->where('(a.publish_up IS NULL OR a.publish_up <= ' . $nowDate . ')') - ->where('(a.publish_down IS NULL OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $nowDate . ')') + ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $nowDate . ')'); } // Filter by Date Range or Relative Date diff --git a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php index 87619bbf8c23..552653b0cd01 100644 --- a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php +++ b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php @@ -111,7 +111,7 @@ public static function getList(Registry $params, ArticlesModel $model) // Set ordering $order_map = array( 'm_dsc' => 'a.modified DESC, a.created', - 'mc_dsc' => 'CASE WHEN a.modified IS NULL THEN a.created ELSE a.modified END', + 'mc_dsc' => 'CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up', 'random' => $db->getQuery(true)->rand(), diff --git a/modules/mod_related_items/Helper/RelatedItemsHelper.php b/modules/mod_related_items/Helper/RelatedItemsHelper.php index 57e8f3ef513d..7983df8e4dac 100644 --- a/modules/mod_related_items/Helper/RelatedItemsHelper.php +++ b/modules/mod_related_items/Helper/RelatedItemsHelper.php @@ -115,8 +115,8 @@ public static function getList(&$params) } $query->where('(' . implode(' OR ', $wheres) . ')') - ->where('(a.publish_up IS NULL OR a.publish_up <= ' . $db->quote($now) . ')') - ->where('(a.publish_down IS NULL OR a.publish_down >= ' . $db->quote($now) . ')'); + ->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $db->quote($now) . ')') + ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $db->quote($now) . ')'); // Filter by language if (Multilanguage::isEnabled()) diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index 5e420349ec87..573dfd78bc4e 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -126,8 +126,8 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) } $xwhere = ' AND (ws.condition = 1 OR ws.condition = -2)' - . ' AND (publish_up IS NULL OR publish_up <= ' . $db->quote($now) . ')' - . ' AND (publish_down IS NULL OR publish_down >= ' . $db->quote($now) . ')'; + . ' AND (ISNULL(publish_up) OR publish_up <= ' . $db->quote($now) . ')' + . ' AND (ISNULL(publish_down) OR publish_down >= ' . $db->quote($now) . ')'; // Array of articles in same category correctly ordered. $query = $db->getQuery(true); @@ -252,12 +252,12 @@ private static function getQueryDate($orderDate) { // Use created if modified is not set case 'modified' : - $queryDate = ' CASE WHEN a.modified IS NULL THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END '; break; // Use created as default From e87bc58141505805d6c56c70a86a399d943a2ad1 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 4 Aug 2019 11:16:46 +0200 Subject: [PATCH 5/7] Use $query->isNullDatetime --- .../com_content/Helper/AssociationHelper.php | 5 +++-- components/com_content/Helper/QueryHelper.php | 9 ++++++--- components/com_content/Model/ArchiveModel.php | 4 ++-- components/com_content/Model/ArticleModel.php | 6 +++--- components/com_content/Model/ArticlesModel.php | 8 ++++---- .../Helper/ArticlesLatestHelper.php | 9 +++++---- .../Helper/RelatedItemsHelper.php | 4 ++-- plugins/content/pagenavigation/pagenavigation.php | 14 +++++++------- 8 files changed, 32 insertions(+), 27 deletions(-) diff --git a/components/com_content/Helper/AssociationHelper.php b/components/com_content/Helper/AssociationHelper.php index 874a02a17c31..98f20e5548f4 100644 --- a/components/com_content/Helper/AssociationHelper.php +++ b/components/com_content/Helper/AssociationHelper.php @@ -54,6 +54,7 @@ public static function getAssociations($id = 0, $view = null, $layout = null) $user = Factory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $db = Factory::getDbo(); + $query = $db->getQuery(true); $advClause = array(); // Filter by user groups @@ -68,8 +69,8 @@ public static function getAssociations($id = 0, $view = null, $layout = null) $date = Factory::getDate(); $nowDate = $db->quote($date->toSql()); - $advClause[] = '(ISNULL(c2.publish_up) OR c2.publish_up <= ' . $nowDate . ')'; - $advClause[] = '(ISNULL(c2.publish_down) OR c2.publish_down >= ' . $nowDate . ')'; + $advClause[] = '(' . $query->isNullDatetime(c2.publish_up) . ' OR c2.publish_up <= ' . $nowDate . ')'; + $advClause[] = '(' . $query->isNullDatetime(c2.publish_down) . ' OR c2.publish_down >= ' . $nowDate . ')'; // Filter by published $advClause[] = 'c2.state = 1'; diff --git a/components/com_content/Helper/QueryHelper.php b/components/com_content/Helper/QueryHelper.php index f5e6b18a1f29..a8fd6e8d1f8f 100644 --- a/components/com_content/Helper/QueryHelper.php +++ b/components/com_content/Helper/QueryHelper.php @@ -179,19 +179,22 @@ public static function orderbySecondary($orderby, $orderDate = 'created', Databa */ public static function getQueryDate($orderDate, DatabaseInterface $db = null) { + $db = Factory::getDbo(); + $query = $db->getQuery(true); + switch ($orderDate) { case 'modified' : - $queryDate = ' CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.publish_up) . ' THEN a.created ELSE a.publish_up END '; break; case 'unpublished' : - $queryDate = ' CASE WHEN ISNULL(a.publish_down) THEN a.created ELSE a.publish_down END '; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.publish_down) . ' THEN a.created ELSE a.publish_down END '; break; case 'created' : default : diff --git a/components/com_content/Model/ArchiveModel.php b/components/com_content/Model/ArchiveModel.php index 4899899b6103..2b7f9cce30ab 100644 --- a/components/com_content/Model/ArchiveModel.php +++ b/components/com_content/Model/ArchiveModel.php @@ -198,8 +198,8 @@ public function getYears() ->where($db->quoteName('c.id') . ' = ' . $db->quoteName('wa.item_id')) ->where($db->quoteName('ws.id') . ' = ' . $db->quoteName('wa.stage_id')) ->where($db->quoteName('ws.condition') . '= ' . (int) ContentComponent::CONDITION_ARCHIVED) - ->where('(ISNULL(c.publish_up) OR c.publish_up <= ' . $nowDate . ')') - ->where('(ISNULL(c.publish_down) OR c.publish_down >= ' . $nowDate . ')') + ->where('(' . $query->isNullDatetime(c.publish_up) . ' OR c.publish_up <= ' . $nowDate . ')') + ->where('(' . $query->isNullDatetime(c.publish_down) . ' OR c.publish_down >= ' . $nowDate . ')') ->order('1 ASC'); $db->setQuery($query); diff --git a/components/com_content/Model/ArticleModel.php b/components/com_content/Model/ArticleModel.php index 5dc90fba8a9a..bff1a6ee75c9 100644 --- a/components/com_content/Model/ArticleModel.php +++ b/components/com_content/Model/ArticleModel.php @@ -101,7 +101,7 @@ public function getItem($pk = null) '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 ISNULL(a.modified) THEN a.created ELSE a.modified END as modified, ' . + 'CASE WHEN ' . $query->isNullDatetime(a.modified) . ' 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.images, a.urls, a.attribs, a.version, a.ordering, ' . 'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language' @@ -158,8 +158,8 @@ public function getItem($pk = null) $date = Factory::getDate(); $nowDate = $db->quote($date->toSql()); - $query->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $nowDate . ')') - ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(' . $query->isNullDatetime(a.publish_up) . ' OR a.publish_up <= ' . $nowDate . ')') + ->where('(' . $query->isNullDatetime(a.publish_down) . ' OR a.publish_down >= ' . $nowDate . ')'); } // Filter by published state. diff --git a/components/com_content/Model/ArticlesModel.php b/components/com_content/Model/ArticlesModel.php index 7e348e641d22..d6fede7ba2ea 100644 --- a/components/com_content/Model/ArticlesModel.php +++ b/components/com_content/Model/ArticlesModel.php @@ -208,10 +208,10 @@ protected function getListQuery() '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 ISNULL(a.modified) THEN a.created ELSE a.modified END as modified, ' . + 'CASE WHEN ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, uam.name as modified_by_name,' . // Use created if publish_up is 0 - 'CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END as publish_up,' . + 'CASE WHEN ' . $query->isNullDatetime(a.publish_up) . ' 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, ' . 'a.hits, a.featured, a.language, ' . $query->length('a.fulltext') . ' AS readmore, a.ordering' ) @@ -473,8 +473,8 @@ function ($data) use ($db) // Filter by start and end dates. if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { - $query->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $nowDate . ')') - ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(' . $query->isNullDatetime(a.publish_up) . ' OR a.publish_up <= ' . $nowDate . ')') + ->where('(' . $query->isNullDatetime(a.publish_down) . ' OR a.publish_down >= ' . $nowDate . ')'); } // Filter by Date Range or Relative Date diff --git a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php index 552653b0cd01..5943a54c4af7 100644 --- a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php +++ b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php @@ -39,8 +39,9 @@ abstract class ArticlesLatestHelper public static function getList(Registry $params, ArticlesModel $model) { // Get the Dbo and User object - $db = Factory::getDbo(); - $user = Factory::getUser(); + $db = Factory::getDbo(); + $query = $db->getQuery(true); + $user = Factory::getUser(); // Set application parameters in model $app = Factory::getApplication(); @@ -111,10 +112,10 @@ public static function getList(Registry $params, ArticlesModel $model) // Set ordering $order_map = array( 'm_dsc' => 'a.modified DESC, a.created', - 'mc_dsc' => 'CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END', + 'mc_dsc' => 'CASE WHEN ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up', - 'random' => $db->getQuery(true)->rand(), + 'random' => $query->rand(), ); $ordering = ArrayHelper::getValue($order_map, $params->get('ordering'), 'a.publish_up'); diff --git a/modules/mod_related_items/Helper/RelatedItemsHelper.php b/modules/mod_related_items/Helper/RelatedItemsHelper.php index 7983df8e4dac..da5d141823a4 100644 --- a/modules/mod_related_items/Helper/RelatedItemsHelper.php +++ b/modules/mod_related_items/Helper/RelatedItemsHelper.php @@ -115,8 +115,8 @@ public static function getList(&$params) } $query->where('(' . implode(' OR ', $wheres) . ')') - ->where('(ISNULL(a.publish_up) OR a.publish_up <= ' . $db->quote($now) . ')') - ->where('(ISNULL(a.publish_down) OR a.publish_down >= ' . $db->quote($now) . ')'); + ->where('(' . $query->isNullDatetime(a.publish_up) . ' OR a.publish_up <= ' . $db->quote($now) . ')') + ->where('(' . $query->isNullDatetime(a.publish_down) . ' OR a.publish_down >= ' . $db->quote($now) . ')'); // Filter by language if (Multilanguage::isEnabled()) diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index 573dfd78bc4e..f7d6427ed8df 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -125,13 +125,12 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) break; } - $xwhere = ' AND (ws.condition = 1 OR ws.condition = -2)' - . ' AND (ISNULL(publish_up) OR publish_up <= ' . $db->quote($now) . ')' - . ' AND (ISNULL(publish_down) OR publish_down >= ' . $db->quote($now) . ')'; - - // Array of articles in same category correctly ordered. $query = $db->getQuery(true); + $xwhere = ' AND (ws.condition = 1 OR ws.condition = -2)' + . ' AND (' . $query->isNullDatetime(publish_up) . ' OR publish_up <= ' . $db->quote($now) . ')' + . ' AND (' . $query->isNullDatetime(publish_down) . ' OR publish_down >= ' . $db->quote($now) . ')'; + $case_when = ' CASE WHEN ' . $query->charLength('a.alias', '!=', '0') . ' THEN ' . $query->concatenate(array($query->castAsChar('a.id'), 'a.alias'), ':') . ' ELSE ' . $query->castAsChar('a.id') . ' END AS slug'; @@ -247,17 +246,18 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) private static function getQueryDate($orderDate) { $db = Factory::getDbo(); + $query = $db->getQuery(true); switch ($orderDate) { // Use created if modified is not set case 'modified' : - $queryDate = ' CASE WHEN ISNULL(a.modified) THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN ISNULL(a.publish_up) THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.publish_up) . ' THEN a.created ELSE a.publish_up END '; break; // Use created as default From d088446fd9a9e41c878258caffc0d35d34158649 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 4 Aug 2019 11:22:50 +0200 Subject: [PATCH 6/7] Update QueryHelper.php --- components/com_content/Helper/QueryHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/com_content/Helper/QueryHelper.php b/components/com_content/Helper/QueryHelper.php index a8fd6e8d1f8f..f1e705b3df93 100644 --- a/components/com_content/Helper/QueryHelper.php +++ b/components/com_content/Helper/QueryHelper.php @@ -179,7 +179,7 @@ public static function orderbySecondary($orderby, $orderDate = 'created', Databa */ public static function getQueryDate($orderDate, DatabaseInterface $db = null) { - $db = Factory::getDbo(); + $db = $db ?: Factory::getDbo(); $query = $db->getQuery(true); switch ($orderDate) From 6c30585f9a68518166305838e9666e41ecc0b914 Mon Sep 17 00:00:00 2001 From: Richard Fath Date: Sun, 4 Aug 2019 12:25:20 +0200 Subject: [PATCH 7/7] @richard67 facepalm --- components/com_content/Helper/AssociationHelper.php | 4 ++-- components/com_content/Helper/QueryHelper.php | 6 +++--- components/com_content/Model/ArchiveModel.php | 4 ++-- components/com_content/Model/ArticleModel.php | 6 +++--- components/com_content/Model/ArticlesModel.php | 8 ++++---- .../mod_articles_latest/Helper/ArticlesLatestHelper.php | 2 +- modules/mod_related_items/Helper/RelatedItemsHelper.php | 4 ++-- plugins/content/pagenavigation/pagenavigation.php | 8 ++++---- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/components/com_content/Helper/AssociationHelper.php b/components/com_content/Helper/AssociationHelper.php index 98f20e5548f4..6683cd300305 100644 --- a/components/com_content/Helper/AssociationHelper.php +++ b/components/com_content/Helper/AssociationHelper.php @@ -69,8 +69,8 @@ public static function getAssociations($id = 0, $view = null, $layout = null) $date = Factory::getDate(); $nowDate = $db->quote($date->toSql()); - $advClause[] = '(' . $query->isNullDatetime(c2.publish_up) . ' OR c2.publish_up <= ' . $nowDate . ')'; - $advClause[] = '(' . $query->isNullDatetime(c2.publish_down) . ' OR c2.publish_down >= ' . $nowDate . ')'; + $advClause[] = '(' . $query->isNullDatetime('c2.publish_up') . ' OR c2.publish_up <= ' . $nowDate . ')'; + $advClause[] = '(' . $query->isNullDatetime('c2.publish_down') . ' OR c2.publish_down >= ' . $nowDate . ')'; // Filter by published $advClause[] = 'c2.state = 1'; diff --git a/components/com_content/Helper/QueryHelper.php b/components/com_content/Helper/QueryHelper.php index f1e705b3df93..e3db63865d28 100644 --- a/components/com_content/Helper/QueryHelper.php +++ b/components/com_content/Helper/QueryHelper.php @@ -185,16 +185,16 @@ public static function getQueryDate($orderDate, DatabaseInterface $db = null) switch ($orderDate) { case 'modified' : - $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime('a.modified') . ' THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.publish_up) . ' THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime('a.publish_up') . ' THEN a.created ELSE a.publish_up END '; break; case 'unpublished' : - $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.publish_down) . ' THEN a.created ELSE a.publish_down END '; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime('a.publish_down') . ' THEN a.created ELSE a.publish_down END '; break; case 'created' : default : diff --git a/components/com_content/Model/ArchiveModel.php b/components/com_content/Model/ArchiveModel.php index 2b7f9cce30ab..540745463acb 100644 --- a/components/com_content/Model/ArchiveModel.php +++ b/components/com_content/Model/ArchiveModel.php @@ -198,8 +198,8 @@ public function getYears() ->where($db->quoteName('c.id') . ' = ' . $db->quoteName('wa.item_id')) ->where($db->quoteName('ws.id') . ' = ' . $db->quoteName('wa.stage_id')) ->where($db->quoteName('ws.condition') . '= ' . (int) ContentComponent::CONDITION_ARCHIVED) - ->where('(' . $query->isNullDatetime(c.publish_up) . ' OR c.publish_up <= ' . $nowDate . ')') - ->where('(' . $query->isNullDatetime(c.publish_down) . ' OR c.publish_down >= ' . $nowDate . ')') + ->where('(' . $query->isNullDatetime('c.publish_up') . ' OR c.publish_up <= ' . $nowDate . ')') + ->where('(' . $query->isNullDatetime('c.publish_down') . ' OR c.publish_down >= ' . $nowDate . ')') ->order('1 ASC'); $db->setQuery($query); diff --git a/components/com_content/Model/ArticleModel.php b/components/com_content/Model/ArticleModel.php index bff1a6ee75c9..5a62212eff2d 100644 --- a/components/com_content/Model/ArticleModel.php +++ b/components/com_content/Model/ArticleModel.php @@ -101,7 +101,7 @@ public function getItem($pk = null) '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 ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END as modified, ' . + 'CASE WHEN ' . $query->isNullDatetime('a.modified') . ' 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.images, a.urls, a.attribs, a.version, a.ordering, ' . 'a.metakey, a.metadesc, a.access, a.hits, a.metadata, a.featured, a.language' @@ -158,8 +158,8 @@ public function getItem($pk = null) $date = Factory::getDate(); $nowDate = $db->quote($date->toSql()); - $query->where('(' . $query->isNullDatetime(a.publish_up) . ' OR a.publish_up <= ' . $nowDate . ')') - ->where('(' . $query->isNullDatetime(a.publish_down) . ' OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(' . $query->isNullDatetime('a.publish_up') . ' OR a.publish_up <= ' . $nowDate . ')') + ->where('(' . $query->isNullDatetime('a.publish_down') . ' OR a.publish_down >= ' . $nowDate . ')'); } // Filter by published state. diff --git a/components/com_content/Model/ArticlesModel.php b/components/com_content/Model/ArticlesModel.php index d6fede7ba2ea..d2f028e33686 100644 --- a/components/com_content/Model/ArticlesModel.php +++ b/components/com_content/Model/ArticlesModel.php @@ -208,10 +208,10 @@ protected function getListQuery() '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 ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END as modified, ' . + 'CASE WHEN ' . $query->isNullDatetime('a.modified') . ' THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, uam.name as modified_by_name,' . // Use created if publish_up is 0 - 'CASE WHEN ' . $query->isNullDatetime(a.publish_up) . ' THEN a.created ELSE a.publish_up END as publish_up,' . + 'CASE WHEN ' . $query->isNullDatetime('a.publish_up') . ' 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, ' . 'a.hits, a.featured, a.language, ' . $query->length('a.fulltext') . ' AS readmore, a.ordering' ) @@ -473,8 +473,8 @@ function ($data) use ($db) // Filter by start and end dates. if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) { - $query->where('(' . $query->isNullDatetime(a.publish_up) . ' OR a.publish_up <= ' . $nowDate . ')') - ->where('(' . $query->isNullDatetime(a.publish_down) . ' OR a.publish_down >= ' . $nowDate . ')'); + $query->where('(' . $query->isNullDatetime('a.publish_up') . ' OR a.publish_up <= ' . $nowDate . ')') + ->where('(' . $query->isNullDatetime('a.publish_down') . ' OR a.publish_down >= ' . $nowDate . ')'); } // Filter by Date Range or Relative Date diff --git a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php index 5943a54c4af7..889120435778 100644 --- a/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php +++ b/modules/mod_articles_latest/Helper/ArticlesLatestHelper.php @@ -112,7 +112,7 @@ public static function getList(Registry $params, ArticlesModel $model) // Set ordering $order_map = array( 'm_dsc' => 'a.modified DESC, a.created', - 'mc_dsc' => 'CASE WHEN ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END', + 'mc_dsc' => 'CASE WHEN ' . $query->isNullDatetime('a.modified') . ' THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up', 'random' => $query->rand(), diff --git a/modules/mod_related_items/Helper/RelatedItemsHelper.php b/modules/mod_related_items/Helper/RelatedItemsHelper.php index da5d141823a4..f448e9183149 100644 --- a/modules/mod_related_items/Helper/RelatedItemsHelper.php +++ b/modules/mod_related_items/Helper/RelatedItemsHelper.php @@ -115,8 +115,8 @@ public static function getList(&$params) } $query->where('(' . implode(' OR ', $wheres) . ')') - ->where('(' . $query->isNullDatetime(a.publish_up) . ' OR a.publish_up <= ' . $db->quote($now) . ')') - ->where('(' . $query->isNullDatetime(a.publish_down) . ' OR a.publish_down >= ' . $db->quote($now) . ')'); + ->where('(' . $query->isNullDatetime('a.publish_up') . ' OR a.publish_up <= ' . $db->quote($now) . ')') + ->where('(' . $query->isNullDatetime('a.publish_down') . ' OR a.publish_down >= ' . $db->quote($now) . ')'); // Filter by language if (Multilanguage::isEnabled()) diff --git a/plugins/content/pagenavigation/pagenavigation.php b/plugins/content/pagenavigation/pagenavigation.php index f7d6427ed8df..0d7f630db499 100644 --- a/plugins/content/pagenavigation/pagenavigation.php +++ b/plugins/content/pagenavigation/pagenavigation.php @@ -128,8 +128,8 @@ public function onContentBeforeDisplay($context, &$row, &$params, $page = 0) $query = $db->getQuery(true); $xwhere = ' AND (ws.condition = 1 OR ws.condition = -2)' - . ' AND (' . $query->isNullDatetime(publish_up) . ' OR publish_up <= ' . $db->quote($now) . ')' - . ' AND (' . $query->isNullDatetime(publish_down) . ' OR publish_down >= ' . $db->quote($now) . ')'; + . ' AND (' . $query->isNullDatetime('publish_up') . ' OR publish_up <= ' . $db->quote($now) . ')' + . ' AND (' . $query->isNullDatetime('publish_down') . ' OR publish_down >= ' . $db->quote($now) . ')'; $case_when = ' CASE WHEN ' . $query->charLength('a.alias', '!=', '0') . ' THEN ' . $query->concatenate(array($query->castAsChar('a.id'), 'a.alias'), ':') @@ -252,12 +252,12 @@ private static function getQueryDate($orderDate) { // Use created if modified is not set case 'modified' : - $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.modified) . ' THEN a.created ELSE a.modified END'; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime('a.modified') . ' THEN a.created ELSE a.modified END'; break; // Use created if publish_up is not set case 'published' : - $queryDate = ' CASE WHEN ' . $query->isNullDatetime(a.publish_up) . ' THEN a.created ELSE a.publish_up END '; + $queryDate = ' CASE WHEN ' . $query->isNullDatetime('a.publish_up') . ' THEN a.created ELSE a.publish_up END '; break; // Use created as default