From 86381310c0914f345eb6c88d4e9ec621996f493c Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 23 Mar 2018 17:48:20 +0000 Subject: [PATCH] Replaced timestamp column with datetime type in tt_tmp_refs. --- WEB-INF/lib/ttUserHelper.class.php | 4 ++-- WEB-INF/templates/footer.tpl | 2 +- dbinstall.php | 12 ++++++++---- mysql.sql | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index 9513a721..e4591ea4 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -415,10 +415,10 @@ class ttUserHelper { static function saveTmpRef($ref, $user_id) { $mdb2 = getConnection(); - $sql = "delete from tt_tmp_refs where timestamp + 86400 < now()"; + $sql = "delete from tt_tmp_refs where created < now() - interval 1 hour"; $affected = $mdb2->exec($sql); - $sql = "insert into tt_tmp_refs (ref, user_id) values(".$mdb2->quote($ref).", $user_id)"; + $sql = "insert into tt_tmp_refs (created, ref, user_id) values(now(), ".$mdb2->quote($ref).", $user_id)"; $affected = $mdb2->exec($sql); } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 21c30273..8f2c0a6c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - - + +
 Anuko Time Tracker 1.17.67.4145 | Copyright © Anuko | +  Anuko Time Tracker 1.17.67.4146 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index 9c2d041b..4d7feeb2 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -805,7 +805,7 @@ if ($_POST) { print "Updated $users_updated users...
\n"; } - if ($_POST["convert11744to11766"]) { + if ($_POST["convert11744to11767"]) { setChange("update `tt_roles` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.44') set rights = replace(rights, 'override_punch_mode,override_date_lock', 'override_punch_mode,override_own_punch_mode,override_date_lock')"); setChange("UPDATE `tt_site_config` SET param_value = '1.17.48' where param_name = 'version_db' and param_value = '1.17.44'"); setChange("update `tt_users` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.48') set role_id = (select id from tt_roles where team_id = 0 and rank = 512) where role = 324"); @@ -856,6 +856,10 @@ if ($_POST) { setChange("ALTER TABLE `tt_teams` drop `timestamp`"); setChange("ALTER TABLE `tt_users` drop `timestamp`"); setChange("UPDATE `tt_site_config` SET param_value = '1.17.66', modified = now() where param_name = 'version_db' and param_value = '1.17.65'"); + setChange("ALTER TABLE `tt_tmp_refs` ADD `created` datetime default NULL AFTER `timestamp`"); + setChange("ALTER TABLE `tt_tmp_refs` drop `timestamp`"); + setChange("delete from `tt_tmp_refs`"); + setChange("UPDATE `tt_site_config` SET param_value = '1.17.67', modified = now() where param_name = 'version_db' and param_value = '1.17.66'"); } if ($_POST["cleanup"]) { @@ -901,7 +905,7 @@ if ($_POST) {

DB Install

-
Create database structure (v1.17.66) + Create database structure (v1.17.67)
(applies only to new installations, do not execute when updating)
@@ -941,8 +945,8 @@ if ($_POST) {

Update database structure (v1.17.44 to v1.17.66)Update database structure (v1.17.44 to v1.17.67)
diff --git a/mysql.sql b/mysql.sql index 48ec0833..df34b775 100644 --- a/mysql.sql +++ b/mysql.sql @@ -226,7 +226,7 @@ create unique index name_idx on tt_invoices(team_id, name, status); # Structure for table tt_tmp_refs. Used for reset password mechanism. # CREATE TABLE `tt_tmp_refs` ( - `timestamp` timestamp default CURRENT_TIMESTAMP, # creation timestamp + `created` datetime default NULL, # creation timestamp `ref` char(32) NOT NULL default '', # unique reference for user, used in urls `user_id` int(11) NOT NULL # user id ); @@ -450,4 +450,4 @@ CREATE TABLE `tt_site_config` ( PRIMARY KEY (`param_name`) ); -INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.66', now()); # TODO: change when structure changes. +INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.17.67', now()); # TODO: change when structure changes. -- 2.20.1