Commit e1dc28f8 authored by pivica's avatar pivica Committed by Jakob Perry
Browse files

Issue #3032742 by joachim, pivica: captcha_cron() removes captcha_sessions...

Issue #3032742 by joachim, pivica: captcha_cron() removes captcha_sessions that may still have open PHP sessions
parent 3a7dadb1
...@@ -111,10 +111,10 @@ function captcha_cron() { ...@@ -111,10 +111,10 @@ function captcha_cron() {
// Get request time. // Get request time.
$request_time = \Drupal::time()->getRequestTime(); $request_time = \Drupal::time()->getRequestTime();
// Remove challenges older than 1 day. // Remove challenges older than PHP's session.gc_maxlifetime value.
$connection = Database::getConnection(); $connection = Database::getConnection();
$connection->delete('captcha_sessions') $connection->delete('captcha_sessions')
->condition('timestamp', $request_time - 60 * 60 * 24, '<') ->condition('timestamp', $request_time - ini_get('session.gc_maxlifetime'), '<')
->execute(); ->execute();
} }
......
...@@ -37,6 +37,8 @@ class CaptchaCronTest extends BrowserTestBase { ...@@ -37,6 +37,8 @@ class CaptchaCronTest extends BrowserTestBase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
ini_set('session.gc_maxlifetime', 60 * 60 * 24);
// Get request time. // Get request time.
$request_time = \Drupal::time()->getRequestTime(); $request_time = \Drupal::time()->getRequestTime();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment