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

[Bug]: Magento 2.4.x and PHP8.x Compatibiliy #131

Closed
1 task done
ecrocombe opened this issue Jan 2, 2023 · 2 comments
Closed
1 task done

[Bug]: Magento 2.4.x and PHP8.x Compatibiliy #131

ecrocombe opened this issue Jan 2, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ecrocombe
Copy link

Contact Details

ecrocombe@outlook.com

What happened?

It appears the devs have done the hard work to address compatibility with Magento 2.4.x and PHP8.x, however they have not pushed a stable release (expected 1.4.6) for us to install.

Until a new version is released, we can install the development version dev-main by:

  1. Adding this github repo to composer
    Edit the composer.json in the magento root directory, find and replace this:
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        }
    ],

WITH

    "repositories": [
        {
            "type": "github",
            "url": "https://github.com/facebookincubator/facebook-for-magento2"
        },
        {
            "type": "composer",
            "url": "https://repo.magento.com/",
            "exclude": ["facebook/facebook-for-magento2"]
        }
    ],
  1. Install with composer
    Install the dev-main release with the command composer require facebook/facebook-for-magento2:dev-main.

  2. Upgrade
    The usual commands we love and enjoy:

bin/magento maint:en
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento setup:static-content:deploy
bin/magento maint:dis

This change will most likely need to be reverted once a stable version has been released as the dev-main may create issues in the future.
This will most likely be in the form of:

  1. composer remove facebook/facebook-for-magento2:dev-main
  2. Remove the above changes to the composer file.
  3. composer require facebook/facebook-for-magento2

I hope this helps you.

Magento Version

2.4.x

Plugin Version

1.4.5

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@pratikvs
Copy link

pratikvs commented Jan 4, 2023

Hi ecrocombe,

I tried the above given solution with the 2.4.5-p1 EE version and PHP8.1. The solution works fine for the nonl-ogged in user but when the user is logged in it gives the below error. Please check and let us know.

`1 exception(s):
Exception #0 (Exception): Deprecated Functionality: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/magento/vendor/facebook/facebook-for-magento2/Helper/MagentoDataHelper.php on line 481

Exception #0 (Exception): Deprecated Functionality: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/magento/vendor/facebook/facebook-for-magento2/Helper/MagentoDataHelper.php on line 481`

@mihaimatei
Copy link

@pratikvs , what I've found is that in the dev-main branch, the update from 2 weeks ago just updated the facebook/php-business-sdk 9.0.3 to >=15.0.0, so the sdk is now compatible with php8.1, but they haven't fixed the strtolower bug.
I've opened a PR for this issue: #132

Until it will be merged into, here is a patch that you can use to fix that:
Create a file like patches/composer/facebook-m2-php8fix/facebook-m2-1.4.5-1.4.6-php8.1--1.patch

--- Helper/MagentoDataHelper.php	2022-03-15 15:40:14.000000000 +0000
+++ Helper/MagentoDataHelper.php	2023-01-05 18:16:03.949331672 +0000
@@ -478,7 +478,7 @@
     }

     private function hashValue($string){
-        return hash('sha256', strtolower($string));
+        return hash('sha256', strtolower((string)$string));
     }

     // TODO Remaining user/custom data methods that can be obtained using Magento.

then also add it into composer.json like:

"patches": {
            "facebook/facebook-for-magento2": {
                "facebook-m2-php81--1": "patches/composer/facebook-m2-php8fix/facebook-m2-1.4.5-1.4.6-php8.1--1.patch"
            }
...         

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

3 participants