Commit f3201a7e authored by alunyov's avatar alunyov Committed by elachlan

Issue #2855165 by alunyov, Znak, gg24, elachlan: Deprecated methods and function

parent 4a08f67f
......@@ -88,8 +88,8 @@ function _captcha_generate_captcha_session($form_id = NULL, $status = CAPTCHA_ST
->fields([
'uid' => $user->id(),
'sid' => session_id(),
'ip_address' => Drupal::request()->getClientIp(),
'timestamp' => REQUEST_TIME,
'ip_address' => \Drupal::request()->getClientIp(),
'timestamp' => \Drupal::time()->getRequestTime(),
'form_id' => $form_id,
'solution' => $solution,
'status' => $status,
......@@ -111,7 +111,7 @@ function _captcha_update_captcha_session($captcha_sid, $solution) {
\Drupal::database()->update('captcha_sessions')
->condition('csid', $captcha_sid)
->fields([
'timestamp' => REQUEST_TIME,
'timestamp' => \Drupal::time()->getRequestTime(),
'solution' => $solution,
])
->execute();
......
......@@ -104,10 +104,13 @@ function captcha_theme() {
* Remove old entries from captcha_sessions table.
*/
function captcha_cron() {
// Get request time.
$request_time = \Drupal::time()->getRequestTime();
// Remove challenges older than 1 day.
$connection = Database::getConnection();
$connection->delete('captcha_sessions')
->condition('timestamp', REQUEST_TIME - 60 * 60 * 24, '<')
->condition('timestamp', $request_time - 60 * 60 * 24, '<')
->execute();
}
......
......@@ -238,7 +238,7 @@ function image_captcha_captcha($op, $captcha_type = '', $captcha_sid = NULL) {
'#theme' => 'image',
'#uri' => Url::fromRoute('image_captcha.generator', [
'session_id' => $captcha_sid,
'timestamp' => REQUEST_TIME,
'timestamp' => \Drupal::time()->getRequestTime(),
])->toString(),
'#width' => $width,
'#height' => $height,
......
......@@ -32,11 +32,14 @@ class CaptchaCronTestCase extends WebTestBase {
public function setUp() {
parent::setUp();
// Get request time.
$request_time = \Drupal::time()->getRequestTime();
// Add removed session.
$time = REQUEST_TIME - 1 - 60 * 60 * 24;
$time = $request_time - 1 - 60 * 60 * 24;
$this->captchaSessions['remove_sid'] = $this->addCaptchaSession('captcha_cron_test_remove', $time);
// Add remain session.
$this->captchaSessions['remain_sid'] = $this->addCaptchaSession('captcha_cron_test_remain', REQUEST_TIME);
$this->captchaSessions['remain_sid'] = $this->addCaptchaSession('captcha_cron_test_remain', $request_time);
}
/**
......
Markdown is supported
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