facebookarchive / facebook-for-magento2

* Pixel on all pages, which trigger events link, PageView, ViewContent, AddToCart, Initiatecheckout and Purchase.* In the background, Syncs the products from the merchants product catalog to Facebook Catalog.* Stores all the data, like pixel id, catalog id, business maanger id, on to the local database on the instance.
Other
46 stars 36 forks source link

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

Open vardhmankamani1 opened 2 years ago

vardhmankamani1 commented 2 years ago

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

angelo983 commented 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 {

angelo983 commented 2 years ago

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

angelo983 commented 2 years ago

/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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

/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 commented 2 years ago

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

dankocrama commented 2 years ago

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

eugenegordienko commented 2 years ago

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

mrramanathan31 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@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

Ig0r-M-magic42 commented 1 year ago

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

Ig0r-M-magic42 commented 1 year ago

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

mrramanathan31 commented 1 year ago

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

mrramanathan31 commented 1 year ago

@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 commented 1 year ago

@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 commented 1 year ago

with vaimo

composer require vaimo/composer-patches

or cweagans

composer require cweagans/composer-patches

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"
            }
        }
    }
}

composer install will remove the packages and install the packages with the patch

ecrocombe commented 1 year ago

Workaround provided in #131