Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Return early from destroy if session ID does not exist
Browse files Browse the repository at this point in the history
Prevents an additional DB query when we already know the session is not present.
  • Loading branch information
weierophinney committed Jun 24, 2016
1 parent 208f4f7 commit c10be09
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/SaveHandler/DbTableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ public function write($id, $data)
*/
public function destroy($id)
{
$exists = (bool) $this->read($id);
if (! (bool) $this->read($id)) {
return true;
}

$deleted = (bool) $this->tableGateway->delete([
return (bool) $this->tableGateway->delete([
$this->options->getIdColumn() => $id,
$this->options->getNameColumn() => $this->sessionName,
]);

return $exists ? $deleted : true;
}

/**
Expand Down

0 comments on commit c10be09

Please sign in to comment.