Open icgdoug opened 2 years ago
I tried contacting their support about this issue but they don't seem to understand the problem. This plugin isn't PHP 8 compatible and I can't see how to request for its update.
Hi @scottbuscemi yes I've tried as well but they don't seem to recognise support queries for the plugin on the core Facebook Business service.
Does anyone have any other contact methods?
The issue, as the error suggests, is that the Normalizer::normalize($field, $data) method is expecting the $data parameter to sent in as a string, but the calling class is sending it as an array.
I don't know whether the calling class or the offending method is 'wrong'... however, a quick and dirty fix is as follows.
Open the file: wp-content/plugins/official-facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Normalizer.php
Find the following section (starting at line 41)
public static function normalize($field, $data) {
if ($data == null || strlen($data) == 0) {
return null;
}
public static function normalize($field, $data) {
// START: Quick fix to avoid PHP Warning that breaks PHP8
// Issue: Some data is sent as an array, but this method expects string
if (is_array($data)) {
$data = $data[0];
}
// END: Quick fix to avoid PHP Warning that breaks PHP8
if ($data == null || strlen($data) == 0) {
return null;
}
That's it... what the code snippet does is check if the $data parameter is an array, and if it is, just grabs the first item.
Cheers Rob
Ps - This is a temporary solution - the proper fix is for Facebook to update / fix the php-business-sdk and re-release the plugin to WordPress :)
The issue is actually in the plugin code, not the business sdk. It was probably introduced in this commit; I have opened PR #32 with the fix.
Superstar, thanks for doing that.
On 10 Mar 2022, at 01:56, Jonathan Horowitz @.***> wrote:
The issue is actually in the plugin code, not the business sdk. It was probably introduced in this commit; I have opened PR #32 with the fix.
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.
Actually, at the time the commit I referenced above was written, the business SDK didn't differentiate between single values and arrays so it would have worked. Starting at version 10.0.1 of the business SDK, they made the distinction between single values and arrays... so this commit would have introduced the bug (when they started using v10.0.1+ of the business SDK).
So it's only been broken since August 2021 (in GitHub anyway... not sure when that code made it to the WordPress repo for general distribution). Still, having this around for seven months is pretty bad; they clearly don't pay a lot of attention to this product... 👎
Even with the latest update (3.0.8), this bug still exists. I do not see any active development to fix issues here, unfortunately.
On the bright side, the fix PR finally got merged...
1 year and 7 months for this bug (and counting since it still isn't released to wordpress.org) 🙄
Just FYI, this issue has been officially resolved in version 3.0.9:
2023-04-03 version 3.0.9
We are constantly getting errors when using PHP 8 with the plugin.
An error of type E_ERROR was caused in line 42 of the file /httpdocs/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 httpdocs/wp-content/plugins/official-facebook-pixel/vendor/facebook/php-business-sdk/src/FacebookAds/Object/ServerSide/Normalizer.php:42
The issue resolves by downgrading to a lower version of PHP