• Resolved mcarner5

    (@mcarner5)


    I’ve got quite a handful of snippets going and one of them seems to be throwing an error:

    2020/11/22 18:21:09 [error] 65613#65613: *16364 FastCGI sent in stderr: “PHP message: PHP Notice: Undefined variable: output in /www/xxx/public/wp-content/plugins/code-snippets/php/snippet-ops.php(446) : eval()’d code on line 8” while reading response header from upstream, client: xxx, server: xxx, request: “GET /product/compact-mirror-with-dual-magnification/ HTTP/1.0”, upstream: “fastcgi://unix:/var/run/php7.4-fpm-xxx.sock:”, host: “xxx”

    Obviously I need to fix something in a snippet, but I’m not sure which one. I edited the ones with the “output” variable so that it should no longer be undefined but It’s still throwing that error. Is there a way to see which snippet is causing this error? One disadvantage to this plugin is that if there is an error it does not point to a specific line in a file as they are all stored on the database.

Viewing 3 replies - 1 through 3 (of 3 total)
  • jetxpert

    (@jetxpert)

    @mcarner5,

    Have you performed a “Search this forum” search to find possible answers to your question?

    Did you follow the directions provided by the developer in his pinned topic?

    Once you do, you will find several methods available to help troubleshoot and fix your issue.

    As you already know, the purpose of this plugin is to simply replace the need to insert a custom PHP code (snippet) directly into your functions.php file. It’s just a tool, that’s all.

    If your website crashes after adding a snippet, it’s mostly because your PHP code is deprecated, does not following proper coding protocol, or conflicts with your theme or other plugin(s). It’s not the developer’s responsibility to fix the PHP code.

    Cheers ??

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @mcarner5,

    Unfortunately, there’s no way to tell the name or ID of the snippet from the error message.

    You’re correct that it will be a snippet with the $output variable on line 8. You can narrow down the list of snippets by using the snippet search function. You can determine whether a particular snippet is in fact the one causing the problem by disabling it temporarily and seeing whether that removes the error.

    Once you’ve figured out the code causing the problem, feel free to post it (or a link to it on gist.github.com or similar) here and I can take a look and suggest how to remove the problem.

    Thread Starter mcarner5

    (@mcarner5)

    I was able to determine which snippet was causing the error. I had forgotten to account for a situation where a null variable was being returned. I’m not sure if there’s much that can be done to aid in troubleshooting this, other than using the search function as you described.

    @bungeshea thank you for the response and thank you for the plugin. I’m definitely getting some use out of it ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to debug a snippet giving an error?’ is closed to new replies.