Skip to content
This repository has been archived by the owner on Apr 30, 2023. It is now read-only.

[Bug]: Does not work with Magento2.4.4 ECE , it shows all pages blank #119

Open
1 task done
vardhmankamani1 opened this issue Jul 19, 2022 · 19 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@vardhmankamani1
Copy link

vardhmankamani1 commented Jul 19, 2022

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

  • I agree to follow this project's Code of Conduct
@vardhmankamani1 vardhmankamani1 added the bug Something isn't working label Jul 19, 2022
@angelo983
Copy link

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 {

@angelo983
Copy link

angelo983 commented Sep 16, 2022

As for:
AdsPixelSettings.php
similar corrections need to be made urgently also in:
Content.php
CustomData.php
Event.php
EventRequest.php
UserData.php

@angelo983
Copy link

/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.

@davirs
Copy link

davirs commented Oct 11, 2022

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?

@angelo983
Copy link

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

@angelo983
Copy link

/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

@angelo983
Copy link

angelo983 commented Oct 12, 2022

vendor/facebook/facebook-for-magento2/Logger/Handler.php
protected $loggerType = Logger::INFO;
in a production environment??? CRAZY CRAZY CRAZY

@dankocrama
Copy link

@zlik Same error here why Facebook is not updating the module to have support for php 8.1 ?

@eugenegordienko
Copy link

@xiangminxufsu @zlik @josejia @fbisaso is there any news regarding this issue?

@mrramanathan31
Copy link

@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 ???

@vardhmankamani1
Copy link
Author

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??''));

@Ig0r-M-magic42
Copy link

@vardhmankamani1 given you have listed the files to be edited in #119 (comment) 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

@Ig0r-M-magic42
Copy link

Ig0r-M-magic42 commented Nov 14, 2022

Update for those interested below are the .patch files based on recommended changes from #119 (comment)

@Ig0r-M-magic42
Copy link

Updated above comment to include file src/FacebookAds/Object/ServerSide/AdsPixelSettings.php as well

@mrramanathan31
Copy link

@Ig0r-M-magic42 Is this patch compatible with Magento 2.4.5-p1 Enterprise edition ?

@mrramanathan31
Copy link

@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 {
* @param integer $offset Offset
* @return boolean
*/

  • public function offsetExists($offset) {
  • public function offsetExists($offset): bool {
    return isset($this->container[$offset]);
    }

@@ -160,7 +160,7 @@ class AdsPixelSettings implements ArrayAccess {
* @param integer $offset Offset
* @return mixed
*/

  • public function offsetGet($offset) {
  • public function offsetGet($offset): mixed {
    return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

@@ -170,7 +170,7 @@ class AdsPixelSettings implements ArrayAccess {
* @param mixed $value Value to be set
* @return void
*/

  • public function offsetSet($offset, $value) {
  • public function offsetSet($offset, $value): void {
    if (is_null($offset)) {
    $this->container[] = $value;
    } else {
    @@ -183,7 +183,7 @@ class AdsPixelSettings implements ArrayAccess {
  • public function offsetUnset($offset) {
  • public function offsetUnset($offset): void {
    unset($this->container[$offset]);
    }`

@Ig0r-M-magic42
Copy link

@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

@henkvalk
Copy link

henkvalk commented Dec 30, 2022

  • Install a composer patcher

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

@ecrocombe
Copy link

Workaround provided in #131

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants