From ceb85d62a963431c5e8b5bf50bcb2e47077cfa87 Mon Sep 17 00:00:00 2001 From: Ares Date: Sun, 22 Oct 2017 20:50:42 +0800 Subject: [PATCH] AbstractWord::getSession()->setExpirationHops() doesn't work at all AbstractWord::getSession() will alway initialize expirationHops to 1 when AbstractWord::session is not set manually.Because Container::setExpirationHops() will refresh "metadata ts" so hops value will never change. --- src/AbstractWord.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/AbstractWord.php b/src/AbstractWord.php index cbeb85c..98b52a0 100644 --- a/src/AbstractWord.php +++ b/src/AbstractWord.php @@ -85,6 +85,13 @@ abstract class AbstractWord extends AbstractAdapter * @var bool */ protected $keepSession = false; + + /** + * Is using default session? + * + * @var bool + */ + protected $useDefaultSession = true; /**#@+ * Error codes @@ -250,8 +257,6 @@ public function getSession() throw new Exception\InvalidArgumentException("Session class $this->sessionClass not found"); } $this->session = new $this->sessionClass('Zend_Form_Captcha_' . $id); - $this->session->setExpirationHops(1, null); - $this->session->setExpirationSeconds($this->getTimeout()); } return $this->session; } @@ -265,6 +270,7 @@ public function getSession() public function setSession(Container $session) { $this->session = $session; + $this->useDefaultSession = false; if ($session) { $this->keepSession = true; } @@ -294,6 +300,10 @@ public function getWord() protected function setWord($word) { $session = $this->getSession(); + if ($this->useDefaultSession) { + $session->setExpirationHops(1, null); + $session->setExpirationSeconds($this->getTimeout()); + } $session->word = $word; $this->word = $word; return $this;