From 6d8fc0dd73523ab315b8ccee1d6627e587a4687c Mon Sep 17 00:00:00 2001 From: Jochen Niebuhr Date: Fri, 4 Sep 2015 14:06:34 +0200 Subject: [PATCH] Passing variables on MongoDB insert When running in hhvm passing a value as reference will result in a fatal error. --- src/OAuth2/Storage/Mongo.php | 79 +++++++++++++++++------------------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/src/OAuth2/Storage/Mongo.php b/src/OAuth2/Storage/Mongo.php index fd5e7be36..95104477a 100644 --- a/src/OAuth2/Storage/Mongo.php +++ b/src/OAuth2/Storage/Mongo.php @@ -97,16 +97,15 @@ public function setClientDetails($client_id, $client_secret = null, $redirect_ur )) ); } else { - $this->collection('client_table')->insert( - array( - 'client_id' => $client_id, - 'client_secret' => $client_secret, - 'redirect_uri' => $redirect_uri, - 'grant_types' => $grant_types, - 'scope' => $scope, - 'user_id' => $user_id, - ) + $client = array( + 'client_id' => $client_id, + 'client_secret' => $client_secret, + 'redirect_uri' => $redirect_uri, + 'grant_types' => $grant_types, + 'scope' => $scope, + 'user_id' => $user_id, ); + $this->collection('client_table')->insert($client); } return true; @@ -147,15 +146,14 @@ public function setAccessToken($access_token, $client_id, $user_id, $expires, $s )) ); } else { - $this->collection('access_token_table')->insert( - array( - 'access_token' => $access_token, - 'client_id' => $client_id, - 'expires' => $expires, - 'user_id' => $user_id, - 'scope' => $scope - ) + $token = array( + 'access_token' => $access_token, + 'client_id' => $client_id, + 'expires' => $expires, + 'user_id' => $user_id, + 'scope' => $scope ); + $this->collection('access_token_table')->insert($token); } return true; @@ -191,17 +189,16 @@ public function setAuthorizationCode($code, $client_id, $user_id, $redirect_uri, )) ); } else { - $this->collection('code_table')->insert( - array( - 'authorization_code' => $code, - 'client_id' => $client_id, - 'user_id' => $user_id, - 'redirect_uri' => $redirect_uri, - 'expires' => $expires, - 'scope' => $scope, - 'id_token' => $id_token, - ) + $token = array( + 'authorization_code' => $code, + 'client_id' => $client_id, + 'user_id' => $user_id, + 'redirect_uri' => $redirect_uri, + 'expires' => $expires, + 'scope' => $scope, + 'id_token' => $id_token, ); + $this->collection('code_table')->insert($token); } return true; @@ -243,15 +240,14 @@ public function getRefreshToken($refresh_token) public function setRefreshToken($refresh_token, $client_id, $user_id, $expires, $scope = null) { - $this->collection('refresh_token_table')->insert( - array( - 'refresh_token' => $refresh_token, - 'client_id' => $client_id, - 'user_id' => $user_id, - 'expires' => $expires, - 'scope' => $scope - ) + $token = array( + 'refresh_token' => $refresh_token, + 'client_id' => $client_id, + 'user_id' => $user_id, + 'expires' => $expires, + 'scope' => $scope ); + $this->collection('refresh_token_table')->insert($token); return true; } @@ -288,14 +284,13 @@ public function setUser($username, $password, $firstName = null, $lastName = nul )) ); } else { - $this->collection('user_table')->insert( - array( - 'username' => $username, - 'password' => $password, - 'first_name' => $firstName, - 'last_name' => $lastName - ) + $user = array( + 'username' => $username, + 'password' => $password, + 'first_name' => $firstName, + 'last_name' => $lastName ); + $this->collection('user_table')->insert($user); } return true;