Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
91265df
Cleanup previous date time queries and implement new ones for com_con…
wilsonge Sep 14, 2019
6f639d4
Update AssociationHelper.php
richard67 Sep 21, 2019
f4b7154
Update QueryHelper.php
richard67 Sep 21, 2019
59a71be
Update ArchiveModel.php
richard67 Sep 21, 2019
8f96759
Update ArticleModel.php
richard67 Sep 21, 2019
45dc872
Update ArticlesModel.php
richard67 Sep 21, 2019
c0b2648
Update default.php
richard67 Sep 21, 2019
76dac7f
Update blog_item.php
richard67 Sep 21, 2019
96258df
Update default_articles.php
richard67 Sep 21, 2019
5c3371e
Update default_item.php
richard67 Sep 21, 2019
0132878
Update multilang.php
richard67 Sep 21, 2019
ce7e3d9
Update RelatedItemsHelper.php
richard67 Sep 21, 2019
969395d
Update pagenavigation.php
richard67 Sep 21, 2019
31c8ff8
Fix my silly mistake with "="
richard67 Sep 25, 2019
39d6ca7
Last of my error with "="
richard67 Sep 25, 2019
a224fb1
Create new content records with null value for published up and down
richard67 Sep 21, 2019
a7b4e1a
Set publish down to null when sanitizing table in articles model
richard67 Sep 21, 2019
9a52355
Move modified check down to store routine
richard67 Sep 25, 2019
a6203d2
SQL for ucm content
richard67 Sep 27, 2019
4ba40e5
Revert menu changes which should be done in separate PR
richard67 Sep 27, 2019
dddc298
PHP changes for ucm content
richard67 Sep 27, 2019
a35045b
Update libraries/src/Table/CoreContent.php
richard67 Sep 27, 2019
05b55bb
No use of nulldate for modified column
richard67 Sep 27, 2019
f3eb0aa
Don't use nullDate in ArticlesModel
richard67 Sep 27, 2019
fb79a4d
Don't handle not nullable ucm content columns
richard67 Sep 27, 2019
ef1af29
SQL code style
richard67 Sep 27, 2019
3445b7a
Handle also not nullable datetime columns
richard67 Sep 28, 2019
e4fd74a
Fix ucm content core modified time
richard67 Sep 28, 2019
d18fc52
Handle also #__ucm_history save_date
richard67 Sep 28, 2019
f05c532
Merge branch 'bugfix/date-columns' into 4.0-dev-bugfix-datetime-colum…
richard67 Sep 28, 2019
7a6f2cb
Merge pull request #41 from richard67/4.0-dev-bugfix-datetime-columns…
wilsonge Sep 28, 2019
772c32b
Merge branch '4.0-dev' into bugfix/date-columns
wilsonge Sep 28, 2019
f3ba33f
Remove useless comment
wilsonge Sep 28, 2019
63a64bb
Update modified also on postgresql (#43)
richard67 Sep 29, 2019
dbf1e6c
Merge branch '4.0-dev' into bugfix/date-columns
wilsonge Oct 3, 2019
dfdc297
Merge branch '4.0-dev' into bugfix/date-columns
Oct 3, 2019
569217e
Update components/com_content/Model/ArticlesModel.php
wilsonge Oct 3, 2019
edcb35f
Update components/com_content/Model/ArticlesModel.php
wilsonge Oct 3, 2019
1b1ed0e
Merge branch '4.0-dev' into bugfix/date-columns
wilsonge Oct 6, 2019
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,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;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ALTER TABLE `#__modules` MODIFY `publish_down` datetime NULL DEFAULT NULL;
ALTER TABLE `#__modules` MODIFY `checked_out_time` datetime NULL DEFAULT NULL;

-- Use 0 instead of '0000-00-00 00:00:00' if you get 'Invalid default value for ...'
UPDATE `#__modules` SET
`publish_up` = CASE WHEN `publish_up` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `publish_up` END,
`publish_down` = CASE WHEN `publish_down` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `publish_down` END,
`checked_out_time` = CASE WHEN `checked_out_time` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `checked_out_time` END;
UPDATE `#__modules` SET `publish_up` = NULL WHERE `publish_up` = '0000-00-00 00:00:00';
UPDATE `#__modules` SET `publish_down` = NULL WHERE `publish_down` = '0000-00-00 00:00:00';
UPDATE `#__modules` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ALTER TABLE `#__contact_details` MODIFY `publish_up` datetime NULL DEFAULT NULL;
ALTER TABLE `#__contact_details` MODIFY `publish_down` datetime NULL DEFAULT NULL;
ALTER TABLE `#__contact_details` MODIFY `checked_out_time` datetime NULL DEFAULT NULL;

UPDATE `#__contact_details` SET
`publish_up` = CASE WHEN `publish_up` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `publish_up` END,
`publish_down` = CASE WHEN `publish_down` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `publish_down` END,
`checked_out_time` = CASE WHEN `checked_out_time` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `checked_out_time` END;
UPDATE `#__contact_details` SET `publish_up` = NULL WHERE `publish_up` = '0000-00-00 00:00:00';
UPDATE `#__contact_details` SET `publish_down` = NULL WHERE `publish_down` = '0000-00-00 00:00:00';
UPDATE `#__contact_details` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ALTER TABLE `#__banners` MODIFY `publish_up` datetime NULL DEFAULT NULL;
ALTER TABLE `#__banners` MODIFY `publish_down` datetime NULL DEFAULT NULL;
ALTER TABLE `#__banners` MODIFY `checked_out_time` datetime NULL DEFAULT NULL;

UPDATE `#__banners` SET
`publish_up` = CASE WHEN `publish_up` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `publish_up` END,
`publish_down` = CASE WHEN `publish_down` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `publish_down` END,
`checked_out_time` = CASE WHEN `checked_out_time` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `checked_out_time` END;
UPDATE `#__banners` SET `publish_up` = NULL WHERE `publish_up` = '0000-00-00 00:00:00';
UPDATE `#__banners` SET `publish_down` = NULL WHERE `publish_down` = '0000-00-00 00:00:00';
UPDATE `#__banners` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ALTER TABLE `#__newsfeeds` MODIFY `publish_up` datetime NULL DEFAULT NULL;
ALTER TABLE `#__newsfeeds` MODIFY `publish_down` datetime NULL DEFAULT NULL;
ALTER TABLE `#__newsfeeds` MODIFY `checked_out_time` datetime NULL DEFAULT NULL;

UPDATE `#__newsfeeds` SET
`publish_up` = CASE WHEN `publish_up` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `publish_up` END,
`publish_down` = CASE WHEN `publish_down` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `publish_down` END,
`checked_out_time` = CASE WHEN `checked_out_time` IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') THEN NULL ELSE `checked_out_time` END;
UPDATE `#__newsfeeds` SET `publish_up` = NULL WHERE `publish_up` = '0000-00-00 00:00:00';
UPDATE `#__newsfeeds` SET `publish_down` = NULL WHERE `publish_down` = '0000-00-00 00:00:00';
UPDATE `#__newsfeeds` SET `checked_out_time` = NULL WHERE `checked_out_time` = '0000-00-00 00:00:00';
Original file line number Diff line number Diff line change
@@ -0,0 +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';
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ALTER TABLE "#__modules" ALTER COLUMN "publish_down" DROP DEFAULT;
ALTER TABLE "#__modules" ALTER COLUMN "checked_out_time" DROP NOT NULL;
ALTER TABLE "#__modules" ALTER COLUMN "checked_out_time" DROP DEFAULT;

UPDATE "#__modules" SET
"publish_up" = CASE WHEN "publish_up" = '1970-01-01 00:00:00' THEN NULL ELSE "publish_up" END,
"publish_down" = CASE WHEN "publish_down" = '1970-01-01 00:00:00' THEN NULL ELSE "publish_down" END,
"checked_out_time" = CASE WHEN "checked_out_time" = '1970-01-01 00:00:00' THEN NULL ELSE "checked_out_time" END;
UPDATE "#__modules" SET "publish_up" = NULL WHERE "publish_up" = '1970-01-01 00:00:00';
UPDATE "#__modules" SET "publish_down" = NULL WHERE "publish_down" = '1970-01-01 00:00:00';
UPDATE "#__modules" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ALTER TABLE "#__contact_details" ALTER COLUMN "publish_down" DROP DEFAULT;
ALTER TABLE "#__contact_details" ALTER COLUMN "checked_out_time" DROP NOT NULL;
ALTER TABLE "#__contact_details" ALTER COLUMN "checked_out_time" DROP DEFAULT;

UPDATE "#__contact_details" SET
"publish_up" = CASE WHEN "publish_up" = '1970-01-01 00:00:00' THEN NULL ELSE "publish_up" END,
"publish_down" = CASE WHEN "publish_down" = '1970-01-01 00:00:00' THEN NULL ELSE "publish_down" END,
"checked_out_time" = CASE WHEN "checked_out_time" = '1970-01-01 00:00:00' THEN NULL ELSE "checked_out_time" END;
UPDATE "#__contact_details" SET "publish_up" = NULL WHERE "publish_up" = '1970-01-01 00:00:00';
UPDATE "#__contact_details" SET "publish_down" = NULL WHERE "publish_down" = '1970-01-01 00:00:00';
UPDATE "#__contact_details" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ALTER TABLE "#__banners" ALTER COLUMN "publish_down" DROP DEFAULT;
ALTER TABLE "#__banners" ALTER COLUMN "checked_out_time" DROP NOT NULL;
ALTER TABLE "#__banners" ALTER COLUMN "checked_out_time" DROP DEFAULT;

UPDATE "#__banners" SET
"publish_up" = CASE WHEN "publish_up" = '1970-01-01 00:00:00' THEN NULL ELSE "publish_up" END,
"publish_down" = CASE WHEN "publish_down" = '1970-01-01 00:00:00' THEN NULL ELSE "publish_down" END,
"checked_out_time" = CASE WHEN "checked_out_time" = '1970-01-01 00:00:00' THEN NULL ELSE "checked_out_time" END;
UPDATE "#__banners" SET "publish_up" = NULL WHERE "publish_up" = '1970-01-01 00:00:00';
UPDATE "#__banners" SET "publish_down" = NULL WHERE "publish_down" = '1970-01-01 00:00:00';
UPDATE "#__banners" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ ALTER TABLE "#__newsfeeds" ALTER COLUMN "publish_down" DROP DEFAULT;
ALTER TABLE "#__newsfeeds" ALTER COLUMN "checked_out_time" DROP NOT NULL;
ALTER TABLE "#__newsfeeds" ALTER COLUMN "checked_out_time" DROP DEFAULT;

UPDATE "#__newsfeeds" SET
"publish_up" = CASE WHEN "publish_up" = '1970-01-01 00:00:00' THEN NULL ELSE "publish_up" END,
"publish_down" = CASE WHEN "publish_down" = '1970-01-01 00:00:00' THEN NULL ELSE "publish_down" END,
"checked_out_time" = CASE WHEN "checked_out_time" = '1970-01-01 00:00:00' THEN NULL ELSE "checked_out_time" END;
UPDATE "#__newsfeeds" SET "publish_up" = NULL WHERE "publish_up" = '1970-01-01 00:00:00';
UPDATE "#__newsfeeds" SET "publish_down" = NULL WHERE "publish_down" = '1970-01-01 00:00:00';
UPDATE "#__newsfeeds" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00';
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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;

ALTER TABLE "#__content" ALTER COLUMN "publish_down" DROP NOT NULL;
ALTER TABLE "#__content" ALTER COLUMN "publish_down" DROP DEFAULT;

ALTER TABLE "#__content" ALTER COLUMN "checked_out_time" DROP NOT NULL;
ALTER TABLE "#__content" ALTER COLUMN "checked_out_time" DROP DEFAULT;

UPDATE "#__content" SET "modified" = "created" 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';
UPDATE "#__content" SET "checked_out_time" = NULL WHERE "checked_out_time" = '1970-01-01 00:00:00';

UPDATE "#__ucm_content" SET "core_modified_time" = "core_created_time"
WHERE "core_type_alias" = 'com_content.article'
AND "core_modified_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';
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
5 changes: 2 additions & 3 deletions components/com_content/Helper/AssociationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ 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[] = '(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';
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/Helper/QueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ public static function getQueryDate($orderDate, DatabaseInterface $db = null)

// 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 a.publish_up IS NULL 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 a.publish_down IS NULL THEN a.created ELSE a.publish_down END ';
break;
case 'created' :
default :
Expand Down
9 changes: 5 additions & 4 deletions components/com_content/Model/ArchiveModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,21 @@ 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());

$nowDate = $db->quote(Factory::getDate()->toSql());

$query = $db->getQuery(true);
$years = $query->year($db->quoteName('c.created'));

$query->select('DISTINCT (' . $years . ')')
->from($db->quoteName('#__content', 'c'))
->from($db->quoteName('#__workflow_associations', 'wa'))
->from($db->quoteName('#__workflow_stages', 'ws'))
->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('(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);
Expand Down
9 changes: 3 additions & 6 deletions components/com_content/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
Expand Down Expand Up @@ -155,13 +153,12 @@ 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('(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.
Expand Down
26 changes: 11 additions & 15 deletions components/com_content/Model/ArticlesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,9 @@ 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,' .
// 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,' .
'a.modified, a.modified_by, uam.name as modified_by_name,' .
// Use created if publish_up is null
'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'
)
Expand Down Expand Up @@ -466,15 +464,13 @@ function ($data) use ($db)
$query->where($authorWhere . $authorAliasWhere);
}

// Define null and now dates
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(Factory::getDate()->toSql());

// 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('(a.publish_up IS NULL OR a.publish_up <= ' . $nowDate . ')')
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove $nullDate = $db->quote($db->getNullDate());.

Copy link
Member

Choose a reason for hiding this comment

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

I will do in my PR for George.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please update in ArticlesModel.php

Copy link
Member

Choose a reason for hiding this comment

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

Where?

Copy link
Contributor

Choose a reason for hiding this comment

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

Line 470. You updated another file ArticleModel.php without the s in Article.

Copy link
Member

Choose a reason for hiding this comment

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

ah i was looking on administrator file ;-)

Copy link
Member

@richard67 richard67 Sep 27, 2019

Choose a reason for hiding this comment

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

Done, made new PR for George for double space removal only. Sorry wrong place.

->where('(a.publish_down IS NULL OR a.publish_down >= ' . $nowDate . ')');
}

// Filter by Date Range or Relative Date
Expand All @@ -484,8 +480,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 . ')'
Expand Down Expand Up @@ -530,13 +526,13 @@ function ($data) use ($db)
if ($monthFilter != '')
{
$query->where(
$db->quote(date("Y-m-d", strtotime($monthFilter)) . ' 00:00:00') . ' <= CASE WHEN a.publish_up = ' .
$db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END'
$db->quote(date("Y-m-d", strtotime($monthFilter)) . ' 00:00:00')
. ' <= CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END'
);

$query->where(
$db->quote(date("Y-m-t", strtotime($monthFilter)) . ' 23:59:59') . ' >= CASE WHEN a.publish_up = ' .
$db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END'
$db->quote(date("Y-m-t", strtotime($monthFilter)) . ' 23:59:59')
. ' >= CASE WHEN a.publish_up IS NULL THEN a.created ELSE a.publish_up END'
);
}
break;
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 (!is_null($this->item->publish_down) && (strtotime($this->item->publish_down) < strtotime(Factory::getDate()))) : ?>
<span class="badge badge-warning"><?php echo Text::_('JEXPIRED'); ?></span>
<?php endif; ?>
</div>
Expand Down
Loading