• Resolved Sean Conklin

    (@seanconklin)


    Hello,

    Whenever I come across an error in the logs like the following, I realize that I could use a column for Line Count in the list of active Snippets. This would help more quickly identify which of the Snippets could be causing a rather generic error to show up in the logs.

    Here’s a sample error log where one needs to locate snippets that contain at least 151 lines of code to review each:

    PHP Warning: Trying to access array offset on false in /srv/htdocs/wp-content/plugins/code-snippets/php/snippet-ops.php(822) : eval()'d code on line 151

    Thank you,

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

    (@0aksmith)

    Hi Sean,

    Thank you for the suggestion. A line-count column could help narrow down warnings like this, and we are already looking into ways to make error messages identify the affected snippet more clearly.

    Code Snippets 3.10.2 includes improved reporting for errors detected while activating snippets, including the error details and a captured stack trace. Runtime warnings can still be less specific because database-backed PHP snippets are executed using PHP’s eval() function. PHP can report line 151 within the evaluated code, but it does not know the snippet’s name or database ID. Several snippets could also contain a line 151, so that information alone cannot reliably identify the responsible snippet.

    As an alternative, you could enable File-Based Execution under Snippets > Settings. Each PHP snippet is then executed from its own generated file, with the snippet ID included in the filename. This can provide more useful file paths and line numbers in PHP logs and stack traces. The reported line may differ slightly from the editor because the generated file includes a small safety header.

    You can read more here:

    https://codesnippets.pro/doc/file-based-execution/

    Thread Starter Sean Conklin

    (@seanconklin)

    On this site there were only three Code Snippets that had 151+ lines and only one which had an array reference missing isset(), so that resolution was fast once I narrowed down the snippets. Thanks for the tip on file-based execution!

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

You must be logged in to reply to this topic.