Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5fb7030
Banner not nullable datetimes defaults - SQL changes
richard67 Sep 21, 2019
5c19496
Change sql for column "reset" to nullable
richard67 Sep 21, 2019
f29cd94
Update 4.0.0-2019-06-28.sql
richard67 Sep 21, 2019
591f5b4
Update install.mysql.utf8.sql
richard67 Sep 21, 2019
2b081e7
Reset nullable and no pseudo null dates in php
richard67 Sep 21, 2019
f94dff0
Banner clients checked out time nullable
richard67 Sep 21, 2019
3274488
Banner tracks track date default value
richard67 Sep 21, 2019
5fbb60b
Merge branch '4.0-dev' into 4.0-dev-datetime-default-com-banners
richard67 Sep 24, 2019
8974017
Merge branch '4.0-dev' into 4.0-dev-datetime-default-com-banners
richard67 Sep 25, 2019
fca292e
Fix also modified < created
richard67 Sep 25, 2019
81528b1
Handle UCM content
richard67 Sep 27, 2019
ed4ed88
No defaults for not nullable, minimize updating old data
richard67 Sep 28, 2019
c846581
Merge pull request #5 from richard67/4.0-dev-datetime-default-com-ban…
richard67 Sep 28, 2019
87212db
Merge branch '4.0-dev' into 4.0-dev-datetime-default-com-banners
richard67 Sep 28, 2019
e3bd1fa
Update modified also on postgresql
richard67 Sep 28, 2019
3557b9a
Merge branch '4.0-dev' into 4.0-dev-datetime-default-com-banners
richard67 Sep 28, 2019
ee73193
Fix check for publish up and down
richard67 Sep 30, 2019
f3e2cd3
don't move modified check
richard67 Sep 30, 2019
49038b8
Merge branch '4.0-dev' into 4.0-dev-datetime-default-com-banners
richard67 Sep 30, 2019
13093bd
Merge branch '4.0-dev' into 4.0-dev-datetime-default-com-banners
richard67 Oct 3, 2019
12a3a2d
Merge remote-tracking branch 'upstream/4.0-dev' into 4.0-dev-datetime…
richard67 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
@@ -1,8 +1,33 @@
ALTER TABLE `#__banners` MODIFY `created` datetime NOT NULL;
ALTER TABLE `#__banners` MODIFY `modified` datetime NOT NULL;

ALTER TABLE `#__banners` MODIFY `reset` datetime NULL DEFAULT NULL;
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;

ALTER TABLE `#__banner_clients` MODIFY `checked_out_time` datetime NULL DEFAULT NULL;

UPDATE `#__banners` SET `modified` = `created` WHERE `modified` = '0000-00-00 00:00:00';

UPDATE `#__banners` SET `reset` = NULL WHERE `reset` = '0000-00-00 00:00:00';
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;
`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 `#__banner_clients` 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_banners.banner'
AND `core_modified_time` = '0000-00-00 00:00:00';

UPDATE `#__ucm_content` SET `core_publish_up` = NULL
WHERE `core_type_alias` = 'com_banners.banner'
AND `core_publish_up` = '0000-00-00 00:00:00';
UPDATE `#__ucm_content` SET `core_publish_down` = NULL
WHERE `core_type_alias` = 'com_banners.banner'
AND `core_publish_down` = '0000-00-00 00:00:00';
UPDATE `#__ucm_content` SET `core_checked_out_time` = NULL
WHERE `core_type_alias` = 'com_banners.banner'
AND `core_checked_out_time` = '0000-00-00 00:00:00';
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
ALTER TABLE "#__banners" ALTER COLUMN "created" DROP DEFAULT;

ALTER TABLE "#__banners" ALTER COLUMN "modified" DROP DEFAULT;

ALTER TABLE "#__banners" ALTER COLUMN "reset" DROP NOT NULL;
ALTER TABLE "#__banners" ALTER COLUMN "reset" DROP DEFAULT;

ALTER TABLE "#__banners" ALTER COLUMN "publish_up" DROP NOT NULL;
ALTER TABLE "#__banners" ALTER COLUMN "publish_up" DROP DEFAULT;

Expand All @@ -7,7 +14,29 @@ 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;

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

UPDATE "#__banners" SET "modified" = "created" WHERE "modified" = '1970-01-01 00:00:00';

UPDATE "#__banners" SET "reset" = NULL WHERE "reset" = '1970-01-01 00:00:00';
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;
"checked_out_time" = CASE WHEN "checked_out_time" = '1970-01-01 00:00:00' THEN NULL ELSE "checked_out_time" END;

UPDATE "#__banner_clients" 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_banners.banner'
AND "core_modified_time" = '1970-01-01 00:00:00';

UPDATE "#__ucm_content" SET "core_publish_up" = NULL
WHERE "core_type_alias" = 'com_banners.banner'
AND "core_publish_up" = '1970-01-01 00:00:00';
UPDATE "#__ucm_content" SET "core_publish_down" = NULL
WHERE "core_type_alias" = 'com_banners.banner'
AND "core_publish_down" = '1970-01-01 00:00:00';
UPDATE "#__ucm_content" SET "core_checked_out_time" = NULL
WHERE "core_type_alias" = 'com_banners.banner'
AND "core_checked_out_time" = '1970-01-01 00:00:00';
5 changes: 2 additions & 3 deletions administrator/components/com_banners/Helper/BannersHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ class BannersHelper extends ContentHelper
public static function updateReset()
{
$db = Factory::getDbo();
$nullDate = $db->getNullDate();
$query = $db->getQuery(true)
->select('*')
->from('#__banners')
->where($db->quote(Factory::getDate()) . ' >= ' . $db->quote('reset'))
->where($db->quoteName('reset') . ' != ' . $db->quote($nullDate) . ' AND ' . $db->quoteName('reset') . '!= NULL')
->where($db->quoteName('reset') . ' IS NOT NULL')
->where(
'(' . $db->quoteName('checked_out') . ' = 0 OR ' . $db->quoteName('checked_out') . ' = '
. (int) $db->quote(Factory::getUser()->id) . ')'
Expand Down Expand Up @@ -79,7 +78,7 @@ public static function updateReset()
switch ($purchaseType)
{
case 1:
$reset = $nullDate;
$reset = null;
break;
case 2:
$date = Factory::getDate('+1 year ' . date('Y-m-d'));
Expand Down
6 changes: 3 additions & 3 deletions administrator/components/com_banners/Table/BannerTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function check()
}

// Check the publish down date is not earlier than publish up.
if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up)
if (!is_null($this->publish_down) && $this->publish_down < $this->publish_up)
{
$this->setError(Text::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));

Expand Down Expand Up @@ -222,7 +222,7 @@ public function store($updateNulls = true)
switch ($purchaseType)
{
case 1:
$this->reset = $this->_db->getNullDate();
$this->reset = null;
break;
case 2:
$date = Factory::getDate('+1 year ' . date('Y-m-d'));
Expand Down Expand Up @@ -338,7 +338,7 @@ public function stick($pks = null, $state = 1, $userId = 0)
// Change the state
$table->sticky = $state;
$table->checked_out = 0;
$table->checked_out_time = $this->_db->getNullDate();
$table->checked_out_time = null;

// Check the row
$table->check();
Expand Down
10 changes: 9 additions & 1 deletion administrator/components/com_banners/Table/ClientTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
*/
class ClientTable extends Table
{
/**
* Indicates that columns fully support the NULL value in the database
*
* @var boolean
* @since __DEPLOY_VERSION__
*/
protected $_supportNullValue = true;

/**
* Constructor
*
Expand All @@ -33,7 +41,7 @@ class ClientTable extends Table
public function __construct(DatabaseDriver $db)
{
$this->typeAlias = 'com_banners.client';
$this->checked_out_time = $db->getNullDate();
$this->checked_out_time = null;

$this->setColumnAlias('published', 'state');

Expand Down
14 changes: 7 additions & 7 deletions administrator/components/com_banners/sql/install.mysql.utf8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ CREATE TABLE IF NOT EXISTS `#__banners` (
`track_clicks` tinyint(4) NOT NULL DEFAULT -1,
`track_impressions` tinyint(4) NOT NULL DEFAULT -1,
`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',
`reset` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`checked_out_time` datetime,
`publish_up` datetime,
`publish_down` datetime,
`reset` datetime,
`created` datetime NOT NULL,
`language` char(7) NOT NULL DEFAULT '',
`created_by` int(10) unsigned NOT NULL DEFAULT 0,
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` datetime NOT NULL,
`modified_by` int(10) unsigned NOT NULL DEFAULT 0,
`version` int(10) unsigned NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
Expand All @@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS `#__banner_clients` (
`extrainfo` text NOT NULL,
`state` tinyint(3) 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',
`checked_out_time` datetime,
`metakey` text NOT NULL,
`own_prefix` tinyint(4) NOT NULL DEFAULT 0,
`metakey_prefix` varchar(400) NOT NULL DEFAULT '',
Expand Down
4 changes: 2 additions & 2 deletions components/com_banners/Model/BannersModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ protected function getListQuery()
->from('#__banners as a')
->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid')
->where('a.state=1')
->where('(' . $query->isNullDatetime('a.publish_up') . ' OR a.publish_up <= ' . $db->quote($nowDate) . ')')
->where('(' . $query->isNullDatetime('a.publish_down') . ' OR a.publish_down >= ' . $db->quote($nowDate) . ')')
->where('(a.publish_up IS NULL OR a.publish_up <= ' . $db->quote($nowDate) . ')')
->where('(a.publish_down IS NULL OR a.publish_down >= ' . $db->quote($nowDate) . ')')
->where('(a.imptotal = 0 OR a.impmade <= a.imptotal)');

if ($cid)
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 @@ -157,12 +157,12 @@ CREATE TABLE IF NOT EXISTS `#__banners` (
`checked_out_time` datetime,
`publish_up` datetime,
`publish_down` datetime,
`reset` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`reset` datetime,
`created` datetime NOT NULL,
`language` char(7) NOT NULL DEFAULT '',
`created_by` int(10) unsigned NOT NULL DEFAULT 0,
`created_by_alias` varchar(255) NOT NULL DEFAULT '',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` datetime NOT NULL,
`modified_by` int(10) unsigned NOT NULL DEFAULT 0,
`version` int(10) unsigned NOT NULL DEFAULT 1,
PRIMARY KEY (`id`),
Expand All @@ -187,7 +187,7 @@ CREATE TABLE IF NOT EXISTS `#__banner_clients` (
`extrainfo` text NOT NULL,
`state` tinyint(3) 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',
`checked_out_time` datetime,
`metakey` text NOT NULL,
`own_prefix` tinyint(4) NOT NULL DEFAULT 0,
`metakey_prefix` varchar(400) NOT NULL DEFAULT '',
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 @@ -163,12 +163,12 @@ CREATE TABLE IF NOT EXISTS "#__banners" (
"checked_out_time" timestamp without time zone,
"publish_up" timestamp without time zone,
"publish_down" timestamp without time zone,
"reset" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"created" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"reset" timestamp without time zone,
"created" timestamp without time zone NOT NULL,
"language" varchar(7) DEFAULT '' NOT NULL,
"created_by" bigint DEFAULT 0 NOT NULL,
"created_by_alias" varchar(255) DEFAULT '' NOT NULL,
"modified" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"modified" timestamp without time zone NOT NULL,
"modified_by" bigint DEFAULT 0 NOT NULL,
"version" bigint DEFAULT 1 NOT NULL,
PRIMARY KEY ("id")
Expand All @@ -191,7 +191,7 @@ CREATE TABLE IF NOT EXISTS "#__banner_clients" (
"extrainfo" text NOT NULL,
"state" smallint 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,
"checked_out_time" timestamp without time zone,
"metakey" text NOT NULL,
"own_prefix" smallint DEFAULT 0 NOT NULL,
"metakey_prefix" varchar(255) DEFAULT '' NOT NULL,
Expand Down