المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : اظهار اخطاء الووردبريس Displaying PHP Errors from admin-ajax.php in Wordpress



Rise Company
27-08-2019, 03:08
اظهار اخطاء الووردبريس Displaying PHP Errors from admin-ajax.php in Wordpress
How to Reduce admin-ajax.php Server Load in WordPress
Ajax returning 400 Bad Request (xhr), admin-ajax.php returns '0'?
Error http 500 “admin-ajax.php”
error /wp-admin/admin-ajax.php cause xhr


https://www.rise.company/forum/images/imported/2019/08/27.png

If you want to see the PHP errors when using ajax, open up the wp-includes/load.php file & on line 336, change this line:


if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) {
@ini_set( 'display_errors', 0 );
} to


if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) {
@ini_set( 'display_errors', 1 );
} You will now be able to see the ajax errors in your browser console. Remember to undo this when finished debugging!

-------------------------------------------------------------------

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
Define the following constants as such. You will be able to see debug.log under wp-content. I usually leave the debug display off too because it causes the headers already sent problem.
EDIT:
So apparently error reporting is turned off for ajax requests in the last of line of the method wp_debug_mode() in wp-includes/load.php


if ( defined( 'XMLRPC_REQUEST' ) || defined( 'REST_REQUEST' ) || ( defined( 'WP_INSTALLING' ) && WP_INSTALLING ) || wp_doing_ajax() ) {
@ini_set( 'display_errors', 0 );
}

https://codex.wordpress.org/Debugging_in_WordPress

المرجع:
https://stackoverflow.com/questions/49489131/displaying-php-errors-from-admin-ajax-php-in-wordpress-4-9
https://www.hostinger.com/tutorials/how-to-fix-admin-ajax-file
https://www.cloudways.com/blog/reduce-admin-ajax-php-related-server-load-wordpress/