• Resolved markisu72

    (@markisu72)


    Hi,

    on PHP 8.x I can produce

    PHP message: PHP Warning: Undefined array key “length” in /home/wp/disk/wordpress/wp-content/plugins/insert-headers-and-footers/includes/class-wpcode-snippet-execute.php(268) : eval()’d code on line 25

    when running this PHP snippet:

    class myClass {
    }
    new myClass;

    on WooCommerce product pages (only).

    Could you help me find out, what’s the issue (in real life, the code is for sure different, but I was able to narrow it down).

    Thanks

    Markus

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @markisu72,

    From the code you have shared there’s no mention of the “length” key mentioned in the notice. That notice comes up when you are trying to access an array key that doesn’t exist so I would look at any other snippets that might be using the key “length” if you are still getting this notice with just the code you mentioned above.

    You mentioned it’s only happening on WooCommerce product pages so if you have any WooCommerce-related snippets that’s the first place I would look at, you should be able to adjust the code adding a check for the “length” key.

    This is not related to the PHP version or specific to WPCode as it seems to be happening when executing a snippet of code.

    If you can share more of the code of the snippets you have active on your site I’d be happy to help pinpoint the issue, please reach out using the form at https://wpcode.com/contact if you want to share code privately.

    Thread Starter markisu72

    (@markisu72)

    Hi @gripgrip

    thanks for your quick reply.
    I’m too tired today.
    The error is sitting in front of the screen 😉

    Best
    Markus

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP warning with PHP 8.x’ is closed to new replies.