Skip to content

Commit

Permalink
set mode to PDO::FETCH_BOTH in fetch calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Sanção committed Nov 6, 2014
1 parent e30f26d commit 5a05861
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/OAuth2/Storage/Pdo.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function checkClientCredentials($client_id, $client_secret = null)
{
$stmt = $this->db->prepare(sprintf('SELECT * from %s where client_id = :client_id', $this->config['client_table']));
$stmt->execute(compact('client_id'));
$result = $stmt->fetch();
$result = $stmt->fetch(\PDO::FETCH_BOTH);

// make this extensible
return $result && $result['client_secret'] == $client_secret;
Expand All @@ -86,7 +86,7 @@ public function isPublicClient($client_id)
$stmt = $this->db->prepare(sprintf('SELECT * from %s where client_id = :client_id', $this->config['client_table']));
$stmt->execute(compact('client_id'));

if (!$result = $stmt->fetch()) {
if (!$result = $stmt->fetch(\PDO::FETCH_BOTH)) {
return false;
}

Expand All @@ -99,7 +99,7 @@ public function getClientDetails($client_id)
$stmt = $this->db->prepare(sprintf('SELECT * from %s where client_id = :client_id', $this->config['client_table']));
$stmt->execute(compact('client_id'));

return $stmt->fetch();
return $stmt->fetch(\PDO::FETCH_BOTH);
}

public function setClientDetails($client_id, $client_secret = null, $redirect_uri = null, $grant_types = null, $scope = null, $user_id = null)
Expand Down Expand Up @@ -133,7 +133,7 @@ public function getAccessToken($access_token)
$stmt = $this->db->prepare(sprintf('SELECT * from %s where access_token = :access_token', $this->config['access_token_table']));

$token = $stmt->execute(compact('access_token'));
if ($token = $stmt->fetch()) {
if ($token = $stmt->fetch(\PDO::FETCH_BOTH)) {
// convert date string back to timestamp
$token['expires'] = strtotime($token['expires']);
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public function getAuthorizationCode($code)
$stmt = $this->db->prepare(sprintf('SELECT * from %s where authorization_code = :code', $this->config['code_table']));
$stmt->execute(compact('code'));

if ($code = $stmt->fetch()) {
if ($code = $stmt->fetch(\PDO::FETCH_BOTH)) {
// convert date string back to timestamp
$code['expires'] = strtotime($code['expires']);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ public function getRefreshToken($refresh_token)
$stmt = $this->db->prepare(sprintf('SELECT * FROM %s WHERE refresh_token = :refresh_token', $this->config['refresh_token_table']));

$token = $stmt->execute(compact('refresh_token'));
if ($token = $stmt->fetch()) {
if ($token = $stmt->fetch(\PDO::FETCH_BOTH)) {
// convert expires to epoch time
$token['expires'] = strtotime($token['expires']);
}
Expand Down Expand Up @@ -308,7 +308,7 @@ public function getUser($username)
$stmt = $this->db->prepare($sql = sprintf('SELECT * from %s where username=:username', $this->config['user_table']));
$stmt->execute(array('username' => $username));

if (!$userInfo = $stmt->fetch()) {
if (!$userInfo = $stmt->fetch(\PDO::FETCH_BOTH)) {
return false;
}

Expand Down Expand Up @@ -341,7 +341,7 @@ public function scopeExists($scope)
$stmt = $this->db->prepare(sprintf('SELECT count(scope) as count FROM %s WHERE scope IN (%s)', $this->config['scope_table'], $whereIn));
$stmt->execute($scope);

if ($result = $stmt->fetch()) {
if ($result = $stmt->fetch(\PDO::FETCH_BOTH)) {
return $result['count'] == count($scope);
}

Expand All @@ -353,7 +353,7 @@ public function getDefaultScope($client_id = null)
$stmt = $this->db->prepare(sprintf('SELECT scope FROM %s WHERE is_default=:is_default', $this->config['scope_table']));
$stmt->execute(array('is_default' => true));

if ($result = $stmt->fetchAll()) {
if ($result = $stmt->fetchAll(\PDO::FETCH_BOTH)) {
$defaultScope = array_map(function ($row) {
return $row['scope'];
}, $result);
Expand Down Expand Up @@ -393,7 +393,7 @@ public function getJti($client_id, $subject, $audience, $expires, $jti)

$stmt->execute(compact('client_id', 'subject', 'audience', 'expires', 'jti'));

if ($result = $stmt->fetch()) {
if ($result = $stmt->fetch(\PDO::FETCH_BOTH)) {
return array(
'issuer' => $result['issuer'],
'subject' => $result['subject'],
Expand All @@ -419,7 +419,7 @@ public function getPublicKey($client_id = null)
$stmt = $this->db->prepare($sql = sprintf('SELECT public_key FROM %s WHERE client_id=:client_id OR client_id IS NULL ORDER BY client_id IS NOT NULL DESC', $this->config['public_key_table']));

$stmt->execute(compact('client_id'));
if ($result = $stmt->fetch()) {
if ($result = $stmt->fetch(\PDO::FETCH_BOTH)) {
return $result['public_key'];
}
}
Expand All @@ -429,7 +429,7 @@ public function getPrivateKey($client_id = null)
$stmt = $this->db->prepare($sql = sprintf('SELECT private_key FROM %s WHERE client_id=:client_id OR client_id IS NULL ORDER BY client_id IS NOT NULL DESC', $this->config['public_key_table']));

$stmt->execute(compact('client_id'));
if ($result = $stmt->fetch()) {
if ($result = $stmt->fetch(\PDO::FETCH_BOTH)) {
return $result['private_key'];
}
}
Expand All @@ -439,7 +439,7 @@ public function getEncryptionAlgorithm($client_id = null)
$stmt = $this->db->prepare($sql = sprintf('SELECT encryption_algorithm FROM %s WHERE client_id=:client_id OR client_id IS NULL ORDER BY client_id IS NOT NULL DESC', $this->config['public_key_table']));

$stmt->execute(compact('client_id'));
if ($result = $stmt->fetch()) {
if ($result = $stmt->fetch(\PDO::FETCH_BOTH)) {
return $result['encryption_algorithm'];
}

Expand Down

0 comments on commit 5a05861

Please sign in to comment.