Open vardhmankamani1 opened 2 years ago
Given the low consideration that the facebook dev team is giving to this topic, here is the solution for compatibility with php 8.1. Declare return types in:
-row 154 public function offsetExists($offset): bool {
-row 163 public function offsetGet($offset): mixed {
-row 173 public function offsetSet($offset, $value): void {
-row 186 public function offsetUnset($offset): void {
As for: AdsPixelSettings.php similar corrections need to be made urgently also in: Content.php CustomData.php Event.php EventRequest.php UserData.php
/vendor/facebook/facebook-for-magento2/Helper/MagentoDataHelper.php on line 481 missing empty string control.
/vendor/facebook/facebook-for-magento2/Model/Feed/CategoryCollection.php on line 306 missing is_array control.
This is a critical issue! All new stores since 2022 are using php 8.1 and gradually the past versions lose support. It is unbelievable that a company that makes billions of dollars has no budget to solve simple compatibility problems!
@angelo983 , Were you able to resolve to make the module usable?
This is a critical issue! All new stores since 2022 are using php 8.1 and gradually the past versions lose support. It is unbelievable that a company that makes billions of dollars has no budget to solve simple compatibility problems!
@angelo983 , Were you able to resolve to make the module usable?
Yes @davirs but I'm still monitoring if data are correctly sent to the Server Pixel
/var/log/facebook-business-extension.log grows rapidly
php-fpm_error.log is continously spammed by this string: WARNING: [pool domain.com] child 123456 said into stdout: "FacebookAds\CrashReporter : Enabled"
about 40.000 rows per day
vendor/facebook/facebook-for-magento2/Logger/Handler.php protected $loggerType = Logger::INFO; in a production environment??? CRAZY CRAZY CRAZY
@zlik Same error here why Facebook is not updating the module to have support for php 8.1 ?
@xiangminxufsu @zlik @josejia @fbisaso is there any news regarding this issue?
@vardhmankamani1 Getting the same issue in Magento 2.4.5-p1 Enterprise edition. Did you get a chance to resolve this? Any suggestion or solution ???
Hello @mrramanathan31 Yes, We created the custom patch for that and now we are testing the module. The following file you need to modify.
vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Event.php
- public function offsetExists($offset) {
+ public function offsetExists($offset): bool {
- public function offsetGet($offset) {
+ public function offsetGet($offset): mixed {
- public function offsetSet($offset, $value) {
+ public function offsetSet($offset, $value): void {
- public function offsetUnset($offset) {
+ public function offsetUnset($offset): void {
vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Content.php
- public function offsetExists($offset) {
+ public function offsetExists($offset): bool {
- public function offsetGet($offset) {
+ public function offsetGet($offset): mixed {
- public function offsetSet($offset, $value) {
+ public function offsetSet($offset, $value): void {
- public function offsetUnset($offset) {
+ public function offsetUnset($offset): void {
vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/UserData.php
- public function offsetExists($offset) {
+ public function offsetExists($offset): bool {
- public function offsetGet($offset) {
+ public function offsetGet($offset): mixed {
- public function offsetSet($offset, $value) {
+ public function offsetSet($offset, $value): void {
- public function offsetUnset($offset) {
+ public function offsetUnset($offset): void {
vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/CustomData.php
- public function offsetExists($offset) {
+ public function offsetExists($offset): bool {
- public function offsetGet($offset) {
+ public function offsetGet($offset): mixed {
- public function offsetSet($offset, $value) {
+ public function offsetSet($offset, $value): void {
- public function offsetUnset($offset) {
+ public function offsetUnset($offset): void {
vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/EventRequest.php
- public function offsetExists($offset) {
+ public function offsetExists($offset): bool {
- public function offsetGet($offset) {
+ public function offsetGet($offset): mixed {
- public function offsetSet($offset, $value) {
+ public function offsetSet($offset, $value): void {
- public function offsetUnset($offset) {
+ public function offsetUnset($offset): void {
vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php
- public function offsetExists($offset) {
+ public function offsetExists($offset): bool {
- public function offsetGet($offset) {
+ public function offsetGet($offset): mixed {
- public function offsetGet($offset) {
+ public function offsetGet($offset): mixed {
- public function offsetSet($offset, $value) {
+ public function offsetSet($offset, $value): void {
- public function offsetUnset($offset) {
+ public function offsetUnset($offset): void {
vendor/facebook/facebook-for-magento2/Model/Feed/CategoryCollection.php
- $response_obj = json_decode($response, true);
+ $response_obj = json_decode($response, true)??[];
vendor/facebook/facebook-for-magento2/Helper/MagentoDataHelper.php
- return hash('sha256', strtolower($string));
+ return hash('sha256', strtolower($string??''));
@vardhmankamani1 given you have listed the files to be edited in https://github.com/facebookincubator/facebook-for-magento2/issues/119#issuecomment-1313322135 and mentioned that a custom patch has been created could you please provide so that we could apply it using https://github.com/cweagans/composer-patches
Update for those interested below are the .patch files based on recommended changes from https://github.com/facebookincubator/facebook-for-magento2/issues/119#issuecomment-1313322135
Updated above comment to include file src/FacebookAds/Object/ServerSide/AdsPixelSettings.php
as well
@Ig0r-M-magic42 Is this patch compatible with Magento 2.4.5-p1 Enterprise edition ?
@Ig0r-M-magic42 Please remove the below duplicated code from your patch for facebook sdk. `diff --git a/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php b/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php index f995a18..21015e5 100644 --- a/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php +++ b/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php @@ -151,7 +151,7 @@ class AdsPixelSettings implements ArrayAccess {
@@ -160,7 +160,7 @@ class AdsPixelSettings implements ArrayAccess {
@@ -170,7 +170,7 @@ class AdsPixelSettings implements ArrayAccess {
@Ig0r-M-magic42 Is this patch compatible with Magento 2.4.5-p1 Enterprise edition ?
I am working on 2.4.4-p2 enterprise update thus cannot confirm this. Spot on in regards with the code duplication, i have removed that now and moved both code to gist
with vaimo
composer require vaimo/composer-patches
or cweagans
composer require cweagans/composer-patches
inside your composer.json
add to extra section:
"extra": {
"magento-force": "override",
"patches-file": "composer.patches.json",
"patches-search": "patches"
},
create file in project root folder composer.patches.json
:
inside this file you add all your patches:
{
"patches": {
"*": {
"Update Facebook Business SDK to php8.1": {
"source": "patches/facebooksdk/facebook-php-business-sdk-compatible-with-php81.patch"
}
}
"facebook/facebook-for-magento2": {
"Update Facebook to php8.1": {
"source": "patches/facebooksdk/FACEBOOK_FOR_MAGENTO2_8_1_SUPPORT.patch"
}
}
}
}
create a folder called patches
inside the root of your project
mkdir patches
all the patch files you added to the above composer.patches.json
file you can add inside this folder.
add the patch files to the folder
mkdir patches/facebooksdk
cd patches/facebooksdk
wget https://gist.githubusercontent.com/Ig0r-M-magic42/479d48832c659874b138229f8625ab98/raw/331c83c0bff46b68ac0fd35222eadf872faf8e5a/FACEBOOK_FOR_MAGENTO2_8_1_SUPPORT.patch
wget https://gist.githubusercontent.com/henkvalk/c224a6a25af38b1b1284b40a316451bc/raw/d35ddadd1cf3f26b5e1e72d1ed3f8900b33cf30e/facebook-php-business-sdk-compatible-with-php81.patch
cd -
composer install
will remove the packages and install the packages with the patch
Workaround provided in #131
Contact Details
No response
What happened?
I Installed Facebook Business Extension(1.4.5) on the frontend all pages are blank and showing below error During inheritance of ArrayAccess: Uncaught Exception: Deprecated Functionality: Return type of FacebookAds\Object\ServerSide\AdsPixelSettings::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Magento Version
2.4.4
Plugin Version
1.4.5
Relevant log output
No response
Code of Conduct