diff options
author | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-30 14:08:13 -0400 |
---|---|---|
committer | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-30 14:08:33 -0400 |
commit | bf9d4e0cdf0fc99555ebd9860665ce898a8d9497 (patch) | |
tree | f597b765e05b11cabc402ec1daac1c5748e503e4 /phpBB/phpbb | |
parent | e53ebb1b68494690749472378de1044d31645f17 (diff) | |
download | forums-bf9d4e0cdf0fc99555ebd9860665ce898a8d9497.tar forums-bf9d4e0cdf0fc99555ebd9860665ce898a8d9497.tar.gz forums-bf9d4e0cdf0fc99555ebd9860665ce898a8d9497.tar.bz2 forums-bf9d4e0cdf0fc99555ebd9860665ce898a8d9497.tar.xz forums-bf9d4e0cdf0fc99555ebd9860665ce898a8d9497.zip |
[feature/oauth] Consolidate repeated query into one function
PHPBB3-11673
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r-- | phpBB/phpbb/auth/provider/oauth/token_storage.php | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/phpBB/phpbb/auth/provider/oauth/token_storage.php b/phpBB/phpbb/auth/provider/oauth/token_storage.php index af85f5598f..b38029c650 100644 --- a/phpBB/phpbb/auth/provider/oauth/token_storage.php +++ b/phpBB/phpbb/auth/provider/oauth/token_storage.php @@ -141,14 +141,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $data['session_id'] = $this->user->data['session_id']; } - $row = $this->_has_acess_token($data); - - if (!$row) - { - return false; - } - - return true; + return $this->_has_acess_token($data); } /** @@ -207,31 +200,25 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface 'provider' => $this->service_name, ); - $row = $this->_has_acess_token($data); - - if (!$row) - { - return false; - } - - return true; + return $this->_has_acess_token($data); } /** * A helper function that performs the query for has access token functions * * @param array $data - * @return mixed + * @return bool */ protected function _has_acess_token($data) { - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + $row = $this->get_access_token_row($data); - return $row; + if (!$row) + { + return false; + } + + return true; } public function retrieve_access_token_by_session() @@ -257,11 +244,7 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface */ protected function _retrieve_access_token($data) { - $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' - WHERE ' . $this->db->sql_build_array('SELECT', $data); - $result = $this->db->sql_query($sql); - $row = $this->db->sql_fetchrow($result); - $this->db->sql_freeresult($result); + $row = $this->get_access_token_row($data); if (!$row) { @@ -282,4 +265,21 @@ class phpbb_auth_provider_oauth_token_storage implements TokenStorageInterface $this->cachedToken = $token; return $token; } + + /** + * A helper function that performs the query for retrieving an access token + * + * @param array $data + * @return mixed + */ + protected function get_access_token_row($data) + { + $sql = 'SELECT oauth_token FROM ' . $this->auth_provider_oauth_table . ' + WHERE ' . $this->db->sql_build_array('SELECT', $data); + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row; + } } |