Skip to content

Commit 852cea8

Browse files
Bug: timestamp in secs (PHP) vs. milliseconds (JS)
1 parent 799d227 commit 852cea8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

gwynethllewelyn/postlocalstorage/event/listener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function check_expiry_time($event)
8181
try
8282
{
8383
/**
84-
* Session length, as defined on the configuration parameters.
84+
* Session length, as defined on the configuration parameters, in seconds.
8585
* If it doesn't exist, or throws an error, we'll set it to zero and that's it.
8686
*
8787
* @var int

gwynethllewelyn/postlocalstorage/ext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ext extends base
2828
*/
2929
public function is_enableable()
3030
{
31-
error_log('[phpBB3 postlocalstorage] my is_enableable() was called!');
31+
// error_log('[phpBB3 postlocalstorage] my is_enableable() was called!');
3232
return phpbb_version_compare(PHPBB_VERSION, '3.3', '>=');
3333
}
3434
}

gwynethllewelyn/postlocalstorage/styles/all/template/postlocalstorage_functions.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@
176176
function() {
177177
/**
178178
* Retrieve the session expiry time that was stamped on the post submit page.
179+
* Force it to a number!
180+
*
179181
* @type {number}
180182
*/
181-
const expiry_time = document.getElementById('expiry-time').innerText.trim();
182-
const dateNow = Date.now();
183-
console.debug("Date.now() is " + dateNow + " and expiry_time is " + expiry_time);
183+
const expiry_time = parseInt(document.getElementById('expiry-time').innerText.trim(), 10);
184+
const dateNow = Math.floor(Date.now() / 1000); // we get milliseconds, so we need to convert to seconds.
185+
console.debug("Date.now() in seconds is " + dateNow + " and expiry_time is " + expiry_time);
184186
if (dateNow > expiry_time) {
185187
// We won't clear anything if the session already expired, so return.
186188
return;

0 commit comments

Comments
 (0)