Support » Plugin: Meta pixel for WordPress » Uncaught TypeError: strlen(): Argument #1 ($string) must be of type string

  • Hey, there!

    Since upgrading to PHP 8, I’m getting the following error:

    Current plugin: Meta pixel for WordPress (version 3.0.8)
    PHP version 8.0.21

    Error Details
    =============
    An error of type E_ERROR was caused in line 42 of the file /public/wp-content/plugins/official-facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Normalizer.php. Error message: Uncaught TypeError: strlen(): Argument #1 ($string) must be of type string, array given in /public/wp-content/plugins/official-facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Normalizer.php:42

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @gelform,

    This is very likely the same issue a lot of people have been having with PHP 8, which is fixed by my PR here:
    https://github.com/facebookincubator/Facebook-Pixel-for-Wordpress/pull/32

    It has been sitting around for a very long time but will hopefully get merged in and released eventually. In the meantime you can apply the changes in that PR to the plugin yourself on your site.

    Thread Starter gelform

    (@gelform)

    Great, thanks!

    Corey

    Following up as this needs to be merged & released.

    @jhorowitz – I am receiving the same error – I can’t figure out from your link what I need to adjust in the files/plugin. Please could you guide me further?

    Thanks

    It appears a very old version of the facebook/php-business-sdk was being used which wasn’t php8.1 compatible. I updated the composer.json file in the plugins root directory by removing the dev requirements as I couldn’t figure out the proper combination and then updated the facebook/php-business-sdk version (https://packagist.org/packages/facebook/php-business-sdk).

    After updating the composer.json I removed the composer.lock file and ran composer update which updated the package and appears to have resolved the issue.

    {
      "name": "facebook/pixel-for-wordpress",
      "description": "Facebook Pixel plugins for wordpress",
      "type": "project",
      "license": "GPL",
      "require": {
        "facebook/php-business-sdk": "16.0.1",
        "techcrunch/wp-async-task": "dev-master"
      },
      "autoload": {
        "psr-4": {
          "FacebookPixelPlugin\\": "./",
          "FacebookPixelPlugin\\Core\\": "core/",
          "FacebookPixelPlugin\\Integration\\": "integration/"
        }
      },
      "replace": {
        "guzzlehttp/guzzle": "*"
      }
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Uncaught TypeError: strlen(): Argument #1 ($string) must be of type string’ is closed to new replies.