• Resolved Marty

    (@bozzmedia)


    The following ended up in my debug.log:

    PHP Deprecated: Invalid characters passed for attempted conversion, these have been ignored in /home/redacted/public_html/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.php on line 375

Viewing 5 replies - 16 through 20 (of 20 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    OK, so the error is no longer happening? The error regarding the unexpected ampersand I suspect is due to copying code from the support forum which may handle escaped characters unexpectedly. Compare bad/good:

    https://gist.github.com/westonruter/6e0a940fa8ccff2ace08365b91a83297#file-good-php

    In any case, it seems your debug log did end up sending the value. Interesting that hex is var(--base-2). That is definitely not expected.

    That does seem like something set from the theme.

    The way to handle this, it seems, is we’ll need to detect the case where a non-hex value is being passed in to the print_editor_color_palette_styles method.

    So here’s what I suggest you try. At this conditional here: https://github.com/ampproject/amp-wp/blob/a373ac8f65f26ee7df7313ff5d734b5704781ab0/src/ReaderThemeSupportFeatures.php#L284-L286

    Add another one after it:

    if ( ! preg_match( '/^[0-9a-f]+$/i', ltrim( $color_option[ self::KEY_COLOR ], '#' ) ) ) {
        continue;
    }

    The method would then look like this: https://gist.github.com/westonruter/e782d795fc5e72095cdbddbc5215fdb2#file-print_editor_color_palette_styles-php-L15-L19

    That should prevent the deprecation notice from occurring. If it works for you, I’ll open a PR to include it in the next release.

    Thread Starter Marty

    (@bozzmedia)

    The error is still happening, I didn’t include it in my last paste:

    [04-Oct-2022 01:48:35 UTC] $hex === "var(--base-2)"
    [04-Oct-2022 01:48:35 UTC] PHP Deprecated:  Invalid characters passed for attempted conversion, these have been ignored in /home/public_html/production/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.php on line 375
    [04-Oct-2022 01:48:35 UTC] PHP Deprecated:  Invalid characters passed for attempted conversion, these have been ignored in /home/public_html/production/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.php on line 376
    [04-Oct-2022 01:48:35 UTC] PHP Deprecated:  Invalid characters passed for attempted conversion, these have been ignored in /home/public_html/production/wp-content/plugins/amp/src/ReaderThemeSupportFeatures.php on line 377
    

    I will try out your suggestion and report back.

    I will

    Thread Starter Marty

    (@bozzmedia)

    Looks like that patch worked, no more errors ??

    Plugin Author Weston Ruter

    (@westonruter)

    Thank you for testing. I’ve filed an issue for this current milestone: https://github.com/ampproject/amp-wp/issues/7285

    Thread Starter Marty

    (@bozzmedia)

    I appreciate the quick response and action on this. Happy to help!

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘PHP 8.0 compatibility error’ is closed to new replies.