• Hi,

    Iā€™m using Meta pixel for WordPress Version: 3.0.8 ā€“ and I want to upgrade to PHP 8.1. while doing so I checked WordPress error log and I see several lines regarding the official-facebook-pixel plugin:

    PHP Deprecated: Return type of FacebookAds\Object\ServerSide\AdsPixelSettings::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in wp-content/plugins/official-facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php on line 154

    PHP Deprecated: 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 in wp-content/plugins/official-facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php on line 163

    PHP Deprecated: Return type of FacebookAds\Object\ServerSide\AdsPixelSettings::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in wp-content/plugins/official-facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php on line 173

    PHP Deprecated: Return type of FacebookAds\Object\ServerSide\AdsPixelSettings::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in wp-content/plugins/official-facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/AdsPixelSettings.php on line 186


    Is there any version to fix it?

    Regards,
    Ram

Viewing 4 replies - 1 through 4 (of 4 total)
  • I have these exact errors too on my site. I subscribed to the topic so I can see replies.

    site:L https://staging-coachcenternl-staging.kinsta.cloud/

    It looks like you are getting a deprecated error when using the offsetSet() method of the FacebookAds\Object\ServerSide\AdsPixelSettings class in PHP. This error is occurring because the return type of the offsetSet() method is not compatible with the ArrayAccess interface, which it is implementing.

    To fix this error, you will need to either change the return type of the offsetSet() method to void, or use the #[\ReturnTypeWillChange] attribute to temporarily suppress the notice.

    Here’s an example of how you could modify the offsetSet() method to fix this error:

    public function offsetSet($offset, $value): void
    {
        if (is_null($offset)) {
            $this->data[] = $value;
        } else {
            $this->data[$offset] = $value;
        }
    }

    Alternatively, you can use the #[\ReturnTypeWillChange] attribute to suppress the notice:

    #[\ReturnTypeWillChange]
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->data[] = $value;
        } else {
            $this->data[$offset] = $value;
        }
    }

    Keep in mind that using the #[\ReturnTypeWillChange] attribute is only a temporary solution and should be used only if you are unable to change the return type of the offsetSet() method to void.

    Thread Starter Ram Freedman

    (@ramf)

    Hi,

    Any news regarding an update for this plugin that will fix the PHP Deprecated errors?

    Regards,

    Ram

    The upstream Facebook PHP SDK dependency was supposed to be bumped from v12 to v16 but that change never made it to the Composer lockfile, so it isn’t actually shipping.

    Follow https://github.com/facebookincubator/Facebook-Pixel-for-Wordpress/issues/42

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP Deprecated errors while using PHP 8.1’ is closed to new replies.