Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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';
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';
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion build/media_source/system/js/fields/calendar.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
});
Expand Down
7 changes: 3 additions & 4 deletions components/com_content/Helper/AssociationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,13 +66,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[] = '(' . $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';
Expand Down
7 changes: 4 additions & 3 deletions components/com_content/Helper/QueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,21 @@ public static function orderbySecondary($orderby, $orderDate = 'created', Databa
public static function getQueryDate($orderDate, DatabaseInterface $db = null)
{
$db = $db ?: Factory::getDbo();
$query = $db->getQuery(true);

switch ($orderDate)
{
case 'modified' :
$queryDate = ' CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' 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 a.publish_up = ' . $db->quote($db->getNullDate()) . ' 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 a.publish_down = ' . $db->quote($db->getNullDate()) . ' 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 :
Expand Down
5 changes: 2 additions & 3 deletions components/com_content/Model/ArchiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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('(' . $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);
Expand Down
8 changes: 3 additions & 5 deletions components/com_content/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' . $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'
Expand Down Expand Up @@ -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('(' . $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.
Expand Down
8 changes: 4 additions & 4 deletions components/com_content/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ' . $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 a.publish_up = ' . $db->quote($db->getNullDate()) . ' 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'
)
Expand Down Expand Up @@ -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('(' . $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
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/tmpl/article/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<?php if (strtotime($this->item->publish_up) > strtotime(Factory::getDate())) : ?>
<span class="badge badge-warning"><?php echo Text::_('JNOTPUBLISHEDYET'); ?></span>
<?php endif; ?>
<?php if ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && $this->item->publish_down != Factory::getDbo()->getNullDate()) : ?>
<?php if ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && !is_null($this->item->publish_down)) : ?>
<span class="badge badge-warning"><?php echo Text::_('JEXPIRED'); ?></span>
<?php endif; ?>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/tmpl/category/blog_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<div class="item-content">
<?php if ($this->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))) : ?>
<div class="system-unpublished">
<?php endif; ?>

Expand Down Expand Up @@ -86,7 +86,7 @@
<?php endif; ?>

<?php if ($this->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))) : ?>
</div>
<?php endif; ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/tmpl/category/default_articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
<?php echo Text::_('JNOTPUBLISHEDYET'); ?>
</span>
<?php endif; ?>
<?php if ((strtotime($article->publish_down) < strtotime(Factory::getDate())) && $article->publish_down != Factory::getDbo()->getNullDate()) : ?>
<?php if ((strtotime($article->publish_down) < strtotime(Factory::getDate())) && !is_null($article->publish_down)) : ?>
<span class="list-published badge badge-warning">
<?php echo Text::_('JEXPIRED'); ?>
</span>
Expand Down
6 changes: 3 additions & 3 deletions components/com_content/tmpl/featured/default_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<div class="item-content">
<?php if ($this->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))) : ?>
<div class="system-unpublished">
<?php endif; ?>

Expand All @@ -52,7 +52,7 @@
<?php if (strtotime($this->item->publish_up) > strtotime(Factory::getDate())) : ?>
<span class="badge badge-warning"><?php echo Text::_('JNOTPUBLISHEDYET'); ?></span>
<?php endif; ?>
<?php if ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && $this->item->publish_down != Factory::getDbo()->getNullDate()) : ?>
<?php if ((strtotime($this->item->publish_down) < strtotime(Factory::getDate())) && !is_null($this->item->publish_down)) : ?>
<span class="badge badge-warning"><?php echo Text::_('JEXPIRED'); ?></span>
<?php endif; ?>

Expand Down Expand Up @@ -104,7 +104,7 @@
<?php endif; ?>

<?php if ($this->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))) : ?>
</div>
<?php endif; ?>

Expand Down
8 changes: 4 additions & 4 deletions installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions installation/sql/postgresql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions libraries/src/Form/Field/CalendarField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this fit better?
if ($this->value !== NULL && $this->value != Factory::getDbo()->getNullDate())

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the value could be an empty string, which isn't null.

{
// Get a date object based on the correct timezone.
$date = Factory::getDate($this->value, 'UTC');
Expand All @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -384,6 +384,11 @@ public function filter($value, $group = null, Registry $input = null)
break;
}

if ($return == '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($return == '')
if ($return === '')

{
$return = null;
}

return $return;
}
}
16 changes: 12 additions & 4 deletions libraries/src/Table/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use === NULL not is_null in code style or?

Suggested change
if (!is_null($this->publish_up) && !is_null($this->publish_up) && $this->publish_up > $this->publish_down)
if ($this->publish_up !== NULL && $this->publish_up !== NULL && $this->publish_up > $this->publish_down)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HLeithner We use both it seems, but is_null() we use by far more often.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc @mbabker changed it in the frame work from is_null to !== NULL I'm and sure if the coding style says anything about this. At least we should use the same in all places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_null() is slower. Also null must be in lowercase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our codestyle has no rules regarding that. If you want us to refactor to that, then I would ask to make a separate issue for that. You might want to bring that up in the ATT. 😉

{
// Swap the dates.
$temp = $this->publish_up;
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions modules/mod_articles_latest/Helper/ArticlesLatestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 (a.modified = ' . $db->quote($db->getNullDate()) . ') 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');
Expand Down
5 changes: 2 additions & 3 deletions modules/mod_related_items/Helper/RelatedItemsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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('(' . $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())
Expand Down
Loading