Skip to content

Commit

Permalink
Merge pull request stefangabos#22 from compwright/master
Browse files Browse the repository at this point in the history
Throw exception instead of dying
  • Loading branch information
stefangabos authored Jan 2, 2019
2 parents 4002dc7 + f426f37 commit 9fdb94b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Zebra_Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ function read($session_id) {
$result = $this->_mysql_query('SELECT GET_LOCK("' . $this->session_lock . '", ' . $this->_mysql_real_escape_string($this->lock_timeout) . ')');

// stop if there was an error
if (!$result || mysqli_num_rows($result) != 1 || !($row = mysqli_fetch_array($result)) || $row[0] != 1) die('Zebra_Session: Could not obtain session lock!');
if (!$result || mysqli_num_rows($result) != 1 || !($row = mysqli_fetch_array($result)) || $row[0] != 1) {
throw new Exception('Zebra_Session: Could not obtain session lock!');
}

// reads session data associated with a session id, but only if
// - the session ID exists;
Expand Down Expand Up @@ -752,10 +754,12 @@ private function _mysql_error() {
private function _mysql_query($query) {

// call "mysqli_query"
$result = mysqli_query($this->link, $query)
$result = mysqli_query($this->link, $query);

// stop if there was an error
or die($this->_mysql_error());
// stop if there was an error
if (!$result) {
throw new Exception($this->_mysql_error());
}

// return the result if query was successful
return $result;
Expand Down

0 comments on commit 9fdb94b

Please sign in to comment.