Skip to content

Commit

Permalink
Use the right tools
Browse files Browse the repository at this point in the history
Signed-off-by: Jessica González <suki@missallsunday.com>
  • Loading branch information
MissAllSunday committed Mar 21, 2017
1 parent 8796fdb commit 93b26c7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/Controllers/Cron.php
Expand Up @@ -196,12 +196,16 @@ function rememberMe()
{
// Remove entries older than 7 days.
$time = time() - 604800;
$db = $this->f3->get('DB');

// Reuse the cron model.
$this->_models['cron']->exec('DELETE FROM '. $this->f3->get('_db.prefix') .'remember WHERE expires < :time', [':time' => $time]);
$r = $db->exec('DELETE FROM '. $this->f3->get('_db.prefix') .'remember WHERE expires > :time', [':time' => $time]);

$this->emit('deleted:'. $r .' entries from remember table');

// Do the same for sessions
$this->_models['cron']->exec('DELETE FROM '. $this->f3->get('_db.prefix') .'ses WHERE stamp < :time', [':time' => $time]);
$s = $db->exec('DELETE FROM '. $this->f3->get('_db.prefix') .'ses WHERE stamp > :time', [':time' => $time]);

$this->emit('deleted:'. $s .' entries from session table');
}

protected function _keywords($keywords, $string)
Expand Down

0 comments on commit 93b26c7

Please sign in to comment.