• hemasusi

    (@hemasusi)


    Hi,

    We have one custom plugin page. That page file path is – wp-content\mu-plugins\custom_api_logs_list.php

    We wrote the coding to list all our API logs from database logs table and list in the table format – look here – https://prnt.sc/Swje1VdgkVDh

    This page file having code to get data from logs table with offset & limit. But facing the slow php error in php slow log – https://prnt.sc/91W0Y-nAtv8r
    and please see other errors also in the screenshot.
    Due to the error, the page is not loading, its taking long time and display timeout error ‘The application did not respond in time’.

    Here is some screenshot from coding –
    https://prnt.sc/WZhGktRewP3X
    https://prnt.sc/rtcaMBwU2ME4
    https://prnt.sc/OlaBSDQ6d7cX
    https://prnt.sc/LkGFGEf1ayvO

    1. If I try print_r or echo before get_var() query, everything is working, no slow in the page. But get_var only not working. All other remaining is working.
    2. I tried get_results() instead of get_var() but thats also triggered error & not loading

    Its happened in WP 6.0.2 only i think.. Bcz before in old version, we didn’t face this issue.

    Can anyone please help.

    • This topic was modified 2 years ago by hemasusi.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter hemasusi

    (@hemasusi)

    Hi,

    Enabling debug mode in DEV & TEST is fine. but in production may show error to customers in website page if debug true.
    So i didn’t try that. Is there any other solution that to print error only in the log files ???

    That’s true, I usually enable errors, check the problem and go back to disable errors. Given that is not an option for you, I suggest you this:

    Edit wp-config.php file edit like this:

    define( 'WP_DEBUG', true );
    
    define( 'WP_DEBUG_LOG', true );
    
    define( 'WP_DEBUG_DISPLAY', false );
    
    @ini_set( 'display_errors', 0 );

    and check for logs in this file:
    wp-content/debug.log

    After checking this error, delete logs or move to other location for security, and also disable the debug mode.

    More detailed guide:
    https://blog.hubspot.com/website/how-to-set-up-wordpress-error-logs-in-wp-config

    Thread Starter hemasusi

    (@hemasusi)

    Hi,

    Thank for the details.

    Because of this line – define( ‘WP_DEBUG_DISPLAY’, false );
    The errors will not display in the site & admin but can view it in the debug.log file???

    After viewing the error, i should empty the file & save ?

    Kindly answer for two questions.

    Hi @hemasusi ,
    Question 1: yes, that line hide the errors from visitors.
    Question 2: I will suggest you to do all the debugging, fix the error, make all the changes to the custom plugin files, and after you finish everything, then you disable the debug mode, and delete this log file.

    The reason for doing this, is that the file route is the default one, and some malicious user could download this file and get information about the server. It’s not a huge security problem, but it’s a good practice to delete it after the end of debugging.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Custom Plugin (mu-plugins) Issue’ is closed to new replies.