From 7aae835cd22126df88a5a2c534162d850fc83589 Mon Sep 17 00:00:00 2001 From: Yves Maerschalck Date: Mon, 7 Mar 2022 10:50:47 +0100 Subject: [PATCH] fix deprecations --- .gitignore | 1 + src/OAuth/OAuthRequest.php | 3 ++- src/OAuth/OAuthSignatureMethod.php | 2 +- .../DataConnector/DataConnector_pdo.php | 18 +++++++++--------- 4 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/src/OAuth/OAuthRequest.php b/src/OAuth/OAuthRequest.php index 6e13262..1a9248d 100644 --- a/src/OAuth/OAuthRequest.php +++ b/src/OAuth/OAuthRequest.php @@ -38,10 +38,11 @@ public static function from_request($http_method = null, $http_url = null, $para $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") ? 'http' : 'https'; + $port = $scheme === 'https' ? '443' : '80'; $http_url = ($http_url) ? $http_url : $scheme . '://' . $_SERVER['HTTP_HOST'] . ':' . - $_SERVER['SERVER_PORT'] . + $port . $_SERVER['REQUEST_URI']; $http_method = ($http_method) ? $http_method : $_SERVER['REQUEST_METHOD']; diff --git a/src/OAuth/OAuthSignatureMethod.php b/src/OAuth/OAuthSignatureMethod.php index 8fae1ed..db5b691 100644 --- a/src/OAuth/OAuthSignatureMethod.php +++ b/src/OAuth/OAuthSignatureMethod.php @@ -56,7 +56,7 @@ public function check_signature($request, $consumer, $token, $signature) { // Avoid a timing leak with a (hopefully) time insensitive compare $result = 0; for ($i = 0; $i < strlen($signature); $i++) { - $result |= ord($built{$i}) ^ ord($signature{$i}); + $result |= ord($built[$i]) ^ ord($signature[$i]); } return $result == 0; diff --git a/src/ToolProvider/DataConnector/DataConnector_pdo.php b/src/ToolProvider/DataConnector/DataConnector_pdo.php index 613be2d..9ea15dd 100644 --- a/src/ToolProvider/DataConnector/DataConnector_pdo.php +++ b/src/ToolProvider/DataConnector/DataConnector_pdo.php @@ -76,7 +76,7 @@ public function loadToolConsumer($consumer) } if ($query->execute()) { - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + while ($row = $query->execute()->fetchAssociative()) { $row = array_change_key_case($row); if (empty($key256) || empty($row['consumer_key']) || ($consumer->getKey() === $row['consumer_key'])) { $consumer->setRecordId(intval($row['consumer_pk'])); @@ -357,7 +357,7 @@ public function getToolConsumers() } if ($ok) { - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + while ($row = $query->execute()->fetchAssociative()) { $row = array_change_key_case($row); $key = empty($row['consumer_key']) ? $row['consumer_key256'] : $row['consumer_key']; $consumer = new ToolProvider\ToolConsumer($key, $this); @@ -464,7 +464,7 @@ public function loadContext($context) } $ok = $query->execute(); if ($ok) { - $row = $query->fetch(PDO::FETCH_ASSOC); + $row = $query->execute()->fetchAssociative(); $ok = ($row !== FALSE); } if ($ok) { @@ -637,7 +637,7 @@ public function loadResourceLink($resourceLink) } $ok = $query->execute(); if ($ok) { - $row = $query->fetch(PDO::FETCH_ASSOC); + $row = $query->execute()->fetchAssociative(); $ok = ($row !== FALSE); } @@ -849,7 +849,7 @@ public function getUserResultSourcedIDsResourceLink($resourceLink, $localOnly, $ $query->bindValue('pid', $id, PDO::PARAM_INT); } if ($query->execute()) { - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + while ($row = $query->execute()->fetchAssociative()) { $row = array_change_key_case($row); $user = ToolProvider\User::fromRecordId($row['user_pk'], $resourceLink->getDataConnector()); if (is_null($idScope)) { @@ -885,7 +885,7 @@ public function getSharesResourceLink($resourceLink) $query = $this->db->prepare($sql); $query->bindValue('id', $id, PDO::PARAM_INT); if ($query->execute()) { - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + while ($row = $query->execute()->fetchAssociative()) { $row = array_change_key_case($row); $share = new ToolProvider\ResourceLinkShare(); $share->resourceLinkId = intval($row['resource_link_pk']); @@ -931,7 +931,7 @@ public function loadConsumerNonce($nonce) $query->bindValue('value', $value, PDO::PARAM_STR); $ok = $query->execute(); if ($ok) { - $row = $query->fetch(PDO::FETCH_ASSOC); + $row = $query->execute()->fetchAssociative(); if ($row === false) { $ok = false; } @@ -997,7 +997,7 @@ public function loadResourceLinkShareKey($shareKey) $query = $this->db->prepare($sql); $query->bindValue('id', $id, PDO::PARAM_STR); if ($query->execute()) { - $row = $query->fetch(PDO::FETCH_ASSOC); + $row = $query->execute()->fetchAssociative(); if ($row !== FALSE) { $row = array_change_key_case($row); if (intval($row['resource_link_pk']) === $shareKey->resourceLinkId) { @@ -1096,7 +1096,7 @@ public function loadUser($user) $query->bindValue('uid', $uid, PDO::PARAM_STR); } if ($query->execute()) { - $row = $query->fetch(PDO::FETCH_ASSOC); + $row = $query->execute()->fetchAssociative(); if ($row !== false) { $row = array_change_key_case($row); $user->setRecordId(intval($row['user_pk']));