Skip to content

Commit

Permalink
Fix touch()
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Dec 15, 2022
1 parent adbd99c commit 84390fd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Model/Table/CaptchasTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,17 @@ public function buildRules(RulesChecker $rules): RulesChecker {
* @return int
*/
public function touch($sessionId, $ip) {
/** @var int $probability */
$probability = Configure::read('Captcha.cleanupProbability') ?? 10;
$this->cleanup((int)$probability);
$probability = (int)Configure::read('Captcha.cleanupProbability') ?: 10;
$this->cleanup($probability);

$captcha = $this->newEntity(
[
'session_id' => $sessionId,
'ip' => $ip,
],
[
'validate' => false,
],
);
if (!$this->save($captcha)) {
throw new BadMethodCallException('Sth went wrong: ' . print_r($captcha->getErrors(), true));
Expand Down

0 comments on commit 84390fd

Please sign in to comment.