diff --git a/public_html/lists/admin/admin.php b/public_html/lists/admin/admin.php
index 557cef1ba..9808aa721 100644
--- a/public_html/lists/admin/admin.php
+++ b/public_html/lists/admin/admin.php
@@ -102,7 +102,7 @@
'statistics' => !empty($_POST['statistics']),
'settings' => !empty($_POST['settings']),
);
- Sql_Query(sprintf('update %s set modified=now(), modifiedby = "%s", privileges = "%s" where id = %d',
+ Sql_Query(sprintf('update %s set modifiedby = "%s", privileges = "%s" where id = %d',
$GLOBALS['tables']['admin'], adminName($_SESSION['logindetails']['id']), sql_escape(serialize($privs)),
$id));
diff --git a/public_html/lists/admin/inc/userlib.php b/public_html/lists/admin/inc/userlib.php
index da8eb273c..f417ca9fb 100644
--- a/public_html/lists/admin/inc/userlib.php
+++ b/public_html/lists/admin/inc/userlib.php
@@ -203,7 +203,7 @@ function addNewUser($email, $password = '')
$blacklist = isBlackListed($email);
$passwordEnc = encryptPass($password);
Sql_Query(sprintf('insert into %s set email = "%s", blacklisted = "%d",
- entered = now(),modified = now(),password = "%s",
+ entered = now(),password = "%s",
passwordchanged = now(),disabled = 0,
uniqid = "%s",htmlemail = 1, uuid = "%s"
', $GLOBALS['tables']['user'], sql_escape($email), $blacklist, $passwordEnc, getUniqid(), (string) uuid::generate(4)));
diff --git a/public_html/lists/admin/initialise.php b/public_html/lists/admin/initialise.php
index 35a5b5b05..c739709a8 100644
--- a/public_html/lists/admin/initialise.php
+++ b/public_html/lists/admin/initialise.php
@@ -167,8 +167,8 @@ function output($message)
$_SESSION['firstinstall'] = 1;
$adminemail = $_REQUEST['adminemail'];
$adminpass = $_REQUEST['adminpassword'];
- Sql_Query(sprintf('insert into %s (loginname,namelc,email,created,modified,password,passwordchanged,superuser,disabled)
- values("%s","%s","%s",now(),now(),"%s",now(),%d,0)',
+ Sql_Query(sprintf('insert into %s (loginname,namelc,email,created,password,passwordchanged,superuser,disabled)
+ values("%s","%s","%s",now(),"%s",now(),%d,0)',
$tables['admin'], 'admin', 'admin', sql_escape($adminemail), encryptPass($adminpass), 1));
//# let's add them as a subscriber as well
diff --git a/public_html/lists/admin/messages.php b/public_html/lists/admin/messages.php
index 880cdd444..4ffb2262f 100644
--- a/public_html/lists/admin/messages.php
+++ b/public_html/lists/admin/messages.php
@@ -215,9 +215,9 @@
$idToDuplicate = sprintf('%d', $_GET['duplicate']);
$action_result .= $GLOBALS['I18N']->get('Copying')." $idToDuplicate ..";
Sql_Query(sprintf('insert into %s (uuid, subject, fromfield, tofield, replyto, message, textmessage, footer, entered,
- modified, embargo, repeatuntil, repeatinterval, requeueinterval, status, htmlformatted, sendformat, template, rsstemplate, owner)
+ embargo, repeatuntil, repeatinterval, requeueinterval, status, htmlformatted, sendformat, template, rsstemplate, owner)
select "%s", subject, fromfield, tofield, replyto, message, textmessage, footer, now(),
- now(), now(), now(), repeatinterval, requeueinterval, "draft", htmlformatted,
+ now(), now(), repeatinterval, requeueinterval, "draft", htmlformatted,
sendformat, template, rsstemplate, "%d" from %s
where id = %d',
$GLOBALS['tables']['message'], (string) Uuid::generate(4), $_SESSION['logindetails']['id'],$GLOBALS['tables']['message'],
diff --git a/public_html/lists/admin/structure.php b/public_html/lists/admin/structure.php
index 703f3e9c1..69ccfce78 100644
--- a/public_html/lists/admin/structure.php
+++ b/public_html/lists/admin/structure.php
@@ -46,7 +46,7 @@
'optedin' => array('tinyint default 0', 'sysexp:Did this subscriber manually confirm'),
'bouncecount' => array('integer default 0', 'sysexp:Number of bounces'),
'entered' => array('datetime', 'sysexp:Entered'),
- 'modified' => array('timestamp', 'sysexp:Last Modified'),
+ 'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'sysexp:Last Modified'),
'uniqid' => array('varchar(255)', 'sysexp:Unique ID'),
'uuid' => array('varchar(36) default ""', 'sys:UUID'),
'htmlemail' => array('tinyint default 0', 'Send this subscriber HTML emails'),
@@ -89,7 +89,7 @@
'listorder' => array('integer', 'Order of listing'),
'prefix' => array('varchar(10)', 'Subject prefix'),
'rssfeed' => array('varchar(255)', 'Rss Feed'),
- 'modified' => array('timestamp', 'Modified'),
+ 'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'Modified'),
'active' => array('tinyint', 'Active'),
'owner' => array('integer', 'Admin who is owner of this list'),
'category' => array('varchar(255) default ""', 'List category'),
@@ -108,7 +108,7 @@
'userid' => array('integer not null', 'Subscriber ID'),
'listid' => array('integer not null', 'List ID'),
'entered' => array('datetime', 'Entered'),
- 'modified' => array('timestamp', 'Modified'),
+ 'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'Modified'),
'primary key' => array('(userid,listid)', 'Primary Key'),
'index_1' => array('userenteredidx (userid,entered)', ''),
'index_2' => array('userlistenteredidx (userid,listid,entered)', ''),
@@ -126,7 +126,7 @@
'textmessage' => array('longtext', 'Text version of Message'),
'footer' => array('text', 'Footer for a message'),
'entered' => array('datetime', 'Entered'),
- 'modified' => array('timestamp', 'Modified'),
+ 'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'Modified'),
'embargo' => array('datetime', 'Time to send message'),
'repeatinterval' => array('integer default 0', 'Number of seconds to repeat the message'),
'repeatuntil' => array('datetime', 'Final time to stop repetition'),
@@ -163,7 +163,7 @@
'messageid' => array('integer not null', 'Message ID'),
'listid' => array('integer not null', 'List ID'),
'entered' => array('datetime', 'Entered'),
- 'modified' => array('timestamp', 'Modified'),
+ 'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'Modified'),
'unique_1' => array('(messageid,listid)', ''),
'index_1' => array('listmessageidx (listid,messageid)', ''),
),
@@ -223,7 +223,7 @@
'sendprocess' => array( // keep track of running send processes to avoid to many running concurrently
'id' => array('integer not null primary key auto_increment', 'ID'),
'started' => array('datetime', 'Start Time'),
- 'modified' => array('timestamp', 'Modified'),
+ 'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'Modified'),
'alive' => array('integer default 1', 'Is this process still alive?'),
'ipaddress' => array('varchar(50)', 'IP Address of who started it'),
'page' => array('varchar(100)', 'The page that this process runs in'),
@@ -261,7 +261,7 @@
'user' => array('integer not null', 'subscriber ID'),
'message' => array('integer not null', 'Message ID'),
'bounce' => array('integer not null', 'Bounce ID'),
- 'time' => array('timestamp', 'When did it bounce'),
+ 'time' => array('timestamp not null default current_timestamp on update current_timestamp', 'When did it bounce'),
'index_1' => array('umbindex (user,message,bounce)', 'index'),
'index_2' => array('useridx (user)', 'index'),
'index_3' => array('msgidx (message)', 'index'),
@@ -273,7 +273,7 @@
'message' => array('integer not null', 'Message ID'),
'forward' => array('varchar(255)', 'Forward email'),
'status' => array('varchar(255)', 'Status of forward'),
- 'time' => array('timestamp', 'When was it forwarded'),
+ 'time' => array('timestamp not null default current_timestamp on update current_timestamp', 'When was it forwarded'),
'index_1' => array('usermessageidx (user,message)', 'index'),
'index_2' => array('useridx (user)', 'index'),
'index_3' => array('messageidx (message)', 'index'),
@@ -290,7 +290,7 @@
'namelc' => array('varchar(255)', 'sys:Normalised loginname'),
'email' => array('varchar(255) not null', 'Email'),
'created' => array('datetime', 'sys:Time Created'),
- 'modified' => array('timestamp', 'sys:Time modified'),
+ 'modified' => array('timestamp not null default current_timestamp on update current_timestamp', 'sys:Time modified'),
'modifiedby' => array('varchar(66)', 'sys:Modified by'),
'password' => array('varchar(255)', 'sys:Password'),
'passwordchanged' => array('date', 'sys:Last time password was changed'),
diff --git a/public_html/lists/admin/upgrade.php b/public_html/lists/admin/upgrade.php
index b10e9697b..7a849a6e2 100644
--- a/public_html/lists/admin/upgrade.php
+++ b/public_html/lists/admin/upgrade.php
@@ -468,6 +468,34 @@ function output($message)
Sql_Query("alter table {$GLOBALS['tables']['admin']} modify modifiedby varchar(66) default ''");
}
+ if (version_compare($dbversion, '3.6.15', '<')) {
+ // Ensure timestamp field does not have null values then give explicit defaults
+ Sql_Query(sprintf('update %s set modified = created where modified is null', $GLOBALS['tables']['admin']));
+ Sql_Query(sprintf('update %s set modified = entered where modified is null', $GLOBALS['tables']['list']));
+ Sql_Query(sprintf('update %s set modified = entered where modified is null', $GLOBALS['tables']['listmessage']));
+ Sql_Query(sprintf('update %s set modified = entered where modified is null', $GLOBALS['tables']['listuser']));
+ Sql_Query(sprintf('update %s set modified = entered where modified is null', $GLOBALS['tables']['message']));
+ Sql_Query(sprintf('update %s set modified = started where modified is null', $GLOBALS['tables']['sendprocess']));
+ Sql_Query(sprintf('update %s set modified = entered where modified is null', $GLOBALS['tables']['user']));
+ Sql_Query(sprintf('update %s set time = current_timestamp where time is null', $GLOBALS['tables']['user_message_bounce']));
+ Sql_Query(sprintf('update %s set time = current_timestamp where time is null', $GLOBALS['tables']['user_message_forward']));
+
+ foreach (['admin', 'list', 'listmessage' , 'listuser', 'message', 'sendprocess', 'user'] as $t) {
+ Sql_Query(sprintf(
+ 'alter table %s modify modified timestamp not null default current_timestamp on update current_timestamp',
+ $GLOBALS['tables'][$t]
+ ));
+ }
+ Sql_Query(sprintf(
+ 'alter table %s modify time timestamp not null default current_timestamp on update current_timestamp',
+ $GLOBALS['tables']['user_message_bounce']
+ ));
+ Sql_Query(sprintf(
+ 'alter table %s modify time timestamp not null default current_timestamp on update current_timestamp',
+ $GLOBALS['tables']['user_message_forward']
+ ));
+ }
+
//# longblobs are better at mixing character encoding. We don't know the encoding of anything we may want to store in cache
//# before converting, it's quickest to clear the cache
clearPageCache();
diff --git a/public_html/lists/index.php b/public_html/lists/index.php
index 10b00fd05..cc6277a1b 100644
--- a/public_html/lists/index.php
+++ b/public_html/lists/index.php
@@ -1145,8 +1145,8 @@ function forwardPage($id)
sendAdminCopy(s('Message Forwarded'),
s('%s has forwarded message %d to %s', $userdata['email'], $mid, $email),
$messagelists);
- Sql_Query(sprintf('insert into %s (user,message,forward,status,time)
- values(%d,%d,"%s","sent",now())',
+ Sql_Query(sprintf('insert into %s (user,message,forward,status)
+ values(%d,%d,"%s","sent")',
$tables['user_message_forward'], $userdata['id'], $mid, $email));
if ($iCountFriends) {
++$nFriends;
@@ -1156,8 +1156,8 @@ function forwardPage($id)
sendAdminCopy(s('Message Forwarded'),
s('%s tried forwarding message %d to %s but failed', $userdata['email'], $mid, $email),
$messagelists);
- Sql_Query(sprintf('insert into %s (user,message,forward,status,time)
- values(%d,%d,"%s","failed",now())',
+ Sql_Query(sprintf('insert into %s (user,message,forward,status)
+ values(%d,%d,"%s","failed")',
$tables['user_message_forward'], $userdata['id'], $mid, $email));
$ok = false;
}