• We have a lot of snippets.

    I know one has an error, but how do I find out which snippet is the one with the problem?

    [16-Jun-2024 09:21:42 UTC] PHP Warning: ?Undefined variable $correct_score in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(100) : eval()’d code on line 17

    I have no idea which snippet has $correct_score.

Viewing 7 replies - 16 through 22 (of 22 total)
  • Thread Starter GideonLupine

    (@gideonlupine)

    You need a space for “PHPCode” to get “PHP Code Snippets”

    Hi,

    Thanks for the feedback. With the latest version, you will receive exception cases if your settings are correct. Please let us know if there are any issues.

    Thanks and Regards,
    Anjali

    Thread Starter GideonLupine

    (@gideonlupine)

    Still no emails received.

    WP Mail SMTP shows nothing in the Debug Events. So I don’t know what is causing the email to fail.

    The server PHP error log looks a little different, but still no clue which snippet has problems.

    I just know that one of the hundred snippets has a bug on line 35 and 36.

    How can I search for the snippet that contains “$leaderdetail” in it?

    What does the “77” mean in “shortcode-handler.php(77)” in the log? Sometimes the number changes:


    [10-Jul-2024 16:47:05 UTC] PHP Warning:  Undefined variable $leaderdetail in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 35

    [10-Jul-2024 16:47:05 UTC] PHP Warning:  Attempt to read property “ID” on null in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 35

    [10-Jul-2024 16:47:05 UTC] PHP Warning:  Undefined variable $leaderdetail in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 36

    [10-Jul-2024 16:47:05 UTC] PHP Warning:  Attempt to read property “ID” on null in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 36

    [10-Jul-2024 16:47:05 UTC] PHP Warning:  Undefined variable $leaderdetail in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 35

    [10-Jul-2024 16:47:05 UTC] PHP Warning:  Attempt to read property “ID” on null in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 35

    [10-Jul-2024 16:47:05 UTC] PHP Warning:  Undefined variable $leaderdetail in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 36

    [10-Jul-2024 16:47:05 UTC] PHP Warning:  Attempt to read property “ID” on null in /var/www/html/website/wp-content/plugins/insert-php-code-snippet/shortcode-handler.php(77) : eval()’d code on line 36

    The PHP warning “Attempt to read property ‘ID’ on null” is likely due to the missing snippet preview draft page issue I previously mentioned. This can be resolved by deactivating and reactivating the plugin to restore the draft page for displaying the snippet preview.

    Regarding line 77, this is where the catch function triggers the error when an exception occurs. However, we do not catch notice and warning errors as they do not break the execution of the code.We can consider addressing this in an upcoming release. If you want to eliminate these logs, you can set the error reporting to exclude notices and warnings. Otherwise, handling these warnings would require customization.

    Thank you and regards,
    Anjali

    Thread Starter GideonLupine

    (@gideonlupine)

    I have over 100 snippets, but I don’t know which one uses $leaderdetail.

    Is there any way for me to find it?

    If I can reduce 100 possible snippets to 10, that would be great.

    I can do searches via PHPmyAdmin. What tables am I looking for?

    I know somebody wrote sloppy php code, and I just want to find and fix it.

    I don’t want to hide and ignore a simple problem I can fix once I locate it.

    Hi,

    To find the snippet using $leaderdetail, you can run the following query in PHPMyAdmin:

    SELECT title, short_code FROM <YOUR WP PREFIX>xyz_ips_short_code WHERE content LIKE '%$leaderdetail%';

    This will help you identify the relevant snippets.
    Thanks and regards,
    Anjali

    Thread Starter GideonLupine

    (@gideonlupine)

    Being able to search to search the “PHP code” field for strings is valuable and essential.

    Using phpMyAdmin with your SQL command worked. It was exactly what I needed to track and fix errors in snippets.

    Can you include this type of search feature in the plugin so I don’t need to go to phpMyAdmin to do such a search?

    Can you include an additional field called “Description” so we can write what and why a snippet exists?

    FEATURE ONE: Snippet Search
    Search for values in the “PHP Code” field.

    Add a Search or Tool section, and put a search form there with a result table that has the title and short_code. Something that would be easy to copy and paste to a notepad.

    I am doing the following SQL search in phpMyAdmin:
    SELECT title, short_code FROM wp_xyz_ips_short_code WHERE content LIKE ‘%$leaderdetail%’;

    FEATURE TWO: Add Description Field
    A place where we can write what and why a snippet exists.

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘Track down snippet with error’ is closed to new replies.