Tables TIMESTAMP default value
atlasan opened this issue · 1 comments
I had an issue while installing:
Timestamp columns in the database has not default value and they are not nullable.
To solve this replace all the occurrences of
TIMESTAMP NOT NULL,
with
TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
in file include\modules\files.php and in file include\modules\user.php
Additionally, I had to dig into the installation process and add a call to debug
when needed, in this case on include\modules\files.php Ln: 2578, where was missing, and in the chain postRestart - createUser - onUserCreated
I had to solve another issue with the TIMESTAMP.. in modules\user.php the timestamp columns from sessions table was compared as numeric value and checked against time() to check for token validity.
In my case mysql timestamps are actually dates, so I had to modify the code as below:
// use the mysqlServer time
$query = "SELECT UNIX_TIMESTAMP(timestamp) AS tstamp, UNIX_TIMESTAMP(NOW()) as now FROM `".DB_PREFIX."sessions` WHERE `token` = '". $token ."' LIMIT 1";
$result = $database->query( $query );
if ($result===false){
debug($database->error,"red");
return null;
}elseif($result->num_rows == 0){
return null;
}
$oTime = $result->fetch_object();
$expTime = $oTime->tstamp + self::$SESSION_EXPIRATION_TIME * 60;
//check if token is expired
if( $expTime < $oTime->now )