From fc064e0c460e38735603001d80abafead080ddad Mon Sep 17 00:00:00 2001 From: ppiechura Date: Thu, 20 Jan 2022 10:36:25 +0100 Subject: [PATCH 1/8] support-php81 --- src/Facebook/FacebookApp.php | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Facebook/FacebookApp.php b/src/Facebook/FacebookApp.php index 804c9bb56..2817b2302 100644 --- a/src/Facebook/FacebookApp.php +++ b/src/Facebook/FacebookApp.php @@ -26,7 +26,7 @@ use Facebook\Authentication\AccessToken; use Facebook\Exceptions\FacebookSDKException; -class FacebookApp implements \Serializable +class FacebookApp { /** * @var string The app ID. @@ -47,8 +47,8 @@ class FacebookApp implements \Serializable public function __construct($id, $secret) { if (!is_string($id) - // Keeping this for BC. Integers greater than PHP_INT_MAX will make is_int() return false - && !is_int($id)) { + // Keeping this for BC. Integers greater than PHP_INT_MAX will make is_int() return false + && !is_int($id)) { throw new FacebookSDKException('The "app_id" must be formatted as a string since many app ID\'s are greater than PHP_INT_MAX on some systems.'); } // We cast as a string in case a valid int was set on a 64-bit system and this is unserialised on a 32-bit system @@ -91,9 +91,9 @@ public function getAccessToken() * * @return string */ - public function serialize() + public function serialize(): array { - return implode('|', [$this->id, $this->secret]); + return implode('|', $this->__serialize()); } /** @@ -101,10 +101,25 @@ public function serialize() * * @param string $serialized */ - public function unserialize($serialized) + public function unserialize(string $serialized): void { - list($id, $secret) = explode('|', $serialized); + $this->__unserialize($serialized); + } + /** + * @internal + */ + public function __serialize(): array + { + return [$this->id, $this->secret]; + } + + /** + * @internal + */ + public function __unserialize(array $data): void + { + list($id, $secret) = explode('|', $data); $this->__construct($id, $secret); } } From a68d30a723001511b3097f02a1b699c5b32462f3 Mon Sep 17 00:00:00 2001 From: ppiechura Date: Thu, 20 Jan 2022 10:38:42 +0100 Subject: [PATCH 2/8] support-php81 --- src/Facebook/Authentication/OAuth2Client.php | 2 +- src/Facebook/Http/RequestBodyMultipart.php | 2 +- src/Facebook/Http/RequestBodyUrlEncoded.php | 2 +- src/Facebook/Url/FacebookUrlManipulator.php | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Facebook/Authentication/OAuth2Client.php b/src/Facebook/Authentication/OAuth2Client.php index 94df9b7b5..3ba05d80a 100644 --- a/src/Facebook/Authentication/OAuth2Client.php +++ b/src/Facebook/Authentication/OAuth2Client.php @@ -143,7 +143,7 @@ public function getAuthorizationUrl($redirectUrl, $state, array $scope = [], arr 'scope' => implode(',', $scope) ]; - return static::BASE_AUTHORIZATION_URL . '/' . $this->graphVersion . '/dialog/oauth?' . http_build_query($params, null, $separator); + return static::BASE_AUTHORIZATION_URL . '/' . $this->graphVersion . '/dialog/oauth?' . http_build_query($params, '', $separator); } /** diff --git a/src/Facebook/Http/RequestBodyMultipart.php b/src/Facebook/Http/RequestBodyMultipart.php index e43695a4f..949080e9c 100644 --- a/src/Facebook/Http/RequestBodyMultipart.php +++ b/src/Facebook/Http/RequestBodyMultipart.php @@ -144,7 +144,7 @@ private function getParamString($name, $value) */ private function getNestedParams(array $params) { - $query = http_build_query($params, null, '&'); + $query = http_build_query($params, '', '&'); $params = explode('&', $query); $result = []; diff --git a/src/Facebook/Http/RequestBodyUrlEncoded.php b/src/Facebook/Http/RequestBodyUrlEncoded.php index c1e35f43d..dee58b9f8 100644 --- a/src/Facebook/Http/RequestBodyUrlEncoded.php +++ b/src/Facebook/Http/RequestBodyUrlEncoded.php @@ -50,6 +50,6 @@ public function __construct(array $params) */ public function getBody() { - return http_build_query($this->params, null, '&'); + return http_build_query($this->params, '', '&'); } } diff --git a/src/Facebook/Url/FacebookUrlManipulator.php b/src/Facebook/Url/FacebookUrlManipulator.php index daeab9c52..490ed1d91 100644 --- a/src/Facebook/Url/FacebookUrlManipulator.php +++ b/src/Facebook/Url/FacebookUrlManipulator.php @@ -53,7 +53,7 @@ public static function removeParamsFromUrl($url, array $paramsToFilter) } if (count($params) > 0) { - $query = '?' . http_build_query($params, null, '&'); + $query = '?' . http_build_query($params, '', '&'); } } @@ -81,7 +81,7 @@ public static function appendParamsToUrl($url, array $newParams = []) } if (strpos($url, '?') === false) { - return $url . '?' . http_build_query($newParams, null, '&'); + return $url . '?' . http_build_query($newParams, '', '&'); } list($path, $query) = explode('?', $url, 2); @@ -94,7 +94,7 @@ public static function appendParamsToUrl($url, array $newParams = []) // Sort for a predicable order ksort($newParams); - return $path . '?' . http_build_query($newParams, null, '&'); + return $path . '?' . http_build_query($newParams, '', '&'); } /** From 8a54abb0193ed569209a7fcb7486c5b7674f73f1 Mon Sep 17 00:00:00 2001 From: ppiechura Date: Thu, 20 Jan 2022 10:43:46 +0100 Subject: [PATCH 3/8] support-php81 --- CHANGELOG.md | 1 + src/Facebook/FacebookApp.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0f80d0b9..76eb8536c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Starting with version 5, the Facebook PHP SDK follows [SemVer](http://semver.org Version 5 of the Facebook PHP SDK is a complete refactor of version 4. It comes loaded with lots of new features and a friendlier API. +- 5.9.0 (2022-01-20) Support php8.1 - 5.7.1 (2018-XX-XX) - 5.7.0 (2018-12-12) - Add `joined` to list of fields to be cast to `\DateTime` (#950) diff --git a/src/Facebook/FacebookApp.php b/src/Facebook/FacebookApp.php index 2817b2302..3cd659b85 100644 --- a/src/Facebook/FacebookApp.php +++ b/src/Facebook/FacebookApp.php @@ -91,7 +91,7 @@ public function getAccessToken() * * @return string */ - public function serialize(): array + public function serialize(): string { return implode('|', $this->__serialize()); } @@ -117,9 +117,9 @@ public function __serialize(): array /** * @internal */ - public function __unserialize(array $data): void + public function __unserialize(string $serialized): void { - list($id, $secret) = explode('|', $data); + list($id, $secret) = explode('|', $serialized); $this->__construct($id, $secret); } } From 3d995ee1c7f3474c410f56c0e61d12625e59e303 Mon Sep 17 00:00:00 2001 From: ppiechura Date: Thu, 20 Jan 2022 10:58:34 +0100 Subject: [PATCH 4/8] support-php81 --- src/Facebook/FacebookApp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Facebook/FacebookApp.php b/src/Facebook/FacebookApp.php index 3cd659b85..6684d5a0e 100644 --- a/src/Facebook/FacebookApp.php +++ b/src/Facebook/FacebookApp.php @@ -26,7 +26,7 @@ use Facebook\Authentication\AccessToken; use Facebook\Exceptions\FacebookSDKException; -class FacebookApp +class FacebookApp implements \Serializable { /** * @var string The app ID. From 00838b6245074575c803186ee9af71f4e2c6b419 Mon Sep 17 00:00:00 2001 From: ppiechura Date: Thu, 20 Jan 2022 12:13:31 +0100 Subject: [PATCH 5/8] support-php81 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9d54abc37..9a0313fce 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^5.4|^7.0" + "php": "^5.4|^7.0|^8.0" }, "require-dev": { "phpunit/phpunit": "~4.0", From faf15cb64a66ac431de02382a786d32ab56f81be Mon Sep 17 00:00:00 2001 From: ppiechura Date: Thu, 20 Jan 2022 12:47:43 +0100 Subject: [PATCH 6/8] support-php81 fix --- src/Facebook/FacebookApp.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Facebook/FacebookApp.php b/src/Facebook/FacebookApp.php index 6684d5a0e..a7a962ab7 100644 --- a/src/Facebook/FacebookApp.php +++ b/src/Facebook/FacebookApp.php @@ -103,7 +103,7 @@ public function serialize(): string */ public function unserialize(string $serialized): void { - $this->__unserialize($serialized); + $this->__unserialize(explode('|', $serialized)); } /** @@ -117,9 +117,9 @@ public function __serialize(): array /** * @internal */ - public function __unserialize(string $serialized): void + public function __unserialize(array $data): void { - list($id, $secret) = explode('|', $serialized); + list($id, $secret) = $data; $this->__construct($id, $secret); } } From f2213a536aa9dceb7bacba11ff8647d0f31dbab6 Mon Sep 17 00:00:00 2001 From: ppiechura Date: Thu, 20 Jan 2022 13:00:50 +0100 Subject: [PATCH 7/8] support-php81 fix --- src/Facebook/FacebookApp.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Facebook/FacebookApp.php b/src/Facebook/FacebookApp.php index a7a962ab7..05838150c 100644 --- a/src/Facebook/FacebookApp.php +++ b/src/Facebook/FacebookApp.php @@ -120,6 +120,7 @@ public function __serialize(): array public function __unserialize(array $data): void { list($id, $secret) = $data; + $this->__construct($id, $secret); } } From c65300ef0d1135109e2d5b894a6742bddf60ca31 Mon Sep 17 00:00:00 2001 From: ppiechura Date: Thu, 20 Jan 2022 13:31:49 +0100 Subject: [PATCH 8/8] support-php81 fix --- src/Facebook/FacebookApp.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Facebook/FacebookApp.php b/src/Facebook/FacebookApp.php index 05838150c..a7a962ab7 100644 --- a/src/Facebook/FacebookApp.php +++ b/src/Facebook/FacebookApp.php @@ -120,7 +120,6 @@ public function __serialize(): array public function __unserialize(array $data): void { list($id, $secret) = $data; - $this->__construct($id, $secret); } }