Use CaptchaSession service instead of PHP Session

[MAILPOET-2248]
This commit is contained in:
Rostislav Wolny
2019-08-05 08:55:16 +02:00
committed by Jack Kitterhing
parent 6a494a2fae
commit 8e1c3b8c03
5 changed files with 47 additions and 19 deletions

View File

@@ -14,9 +14,13 @@ class CaptchaRenderer {
/** @var WPFunctions */
private $wp;
function __construct(UrlHelper $url_helper, WPFunctions $wp) {
/** @var CaptchaSession */
private $captcha_session;
function __construct(UrlHelper $url_helper, WPFunctions $wp, CaptchaSession $captcha_session) {
$this->url_helper = $url_helper;
$this->wp = $wp;
$this->captcha_session = $captcha_session;
}
public function getCaptchaPageTitle() {
@@ -49,7 +53,8 @@ class CaptchaRenderer {
]
);
$form_id = isset($_SESSION[Captcha::SESSION_FORM_KEY]['form_id']) ? (int)$_SESSION[Captcha::SESSION_FORM_KEY]['form_id'] : 0;
$captcha_session_form = $this->captcha_session->getFormData();
$form_id = isset($captcha_session_form['form_id']) ? (int)$captcha_session_form['form_id'] : 0;
$form_model = FormModel::findOne($form_id);
if (!$form_model instanceof FormModel) {
return false;