Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables TIMESTAMP default value #12

Open
atlasan opened this issue Dec 8, 2020 · 1 comment
Open

Tables TIMESTAMP default value #12

atlasan opened this issue Dec 8, 2020 · 1 comment

Comments

@atlasan
Copy link

atlasan commented Dec 8, 2020

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

atlasan added a commit to atlasan/litefilesystem.js that referenced this issue Dec 8, 2020
Mods to solve:
- jagenjo#12
- jagenjo#7

Added debug calls, modified default TIMESTAMP column creation, few other things
@atlasan
Copy link
Author

atlasan commented Dec 8, 2020

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 )

atlasan added a commit to atlasan/litefilesystem.js that referenced this issue Dec 8, 2020
jagenjo#12
- mysql timestamp returns a datetime UTC fixed
- compare saved timestamp + session max duration with mysql time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant