We’ve all encountered the issue: a blank screen or worse, a 500 error on the server. How do you cope with this kind of issue, what do you do to find the culprit and resolve the error.
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
WordCamp Antwerp - 3/3/2018 - Debugging WordPress by Brecht Ryckaert
1. D E B U G G I N G W O R D P R E S S
B R E C H T RY C K A E R T
2. B R E C H T
RY C K A E R T
• Works at combell.com
• WP user since 1.5
• Passionate about
WordPress Security &
Performance
@brechtryckaert
brechtryckaert.com
3. W H E N L A U N C H I N G
Y O U R N E W W E B S I T E
4. O R W H E N U P D AT I N G Y O U R
P L U G I N S O R T H E M E S
5. … O R E V E N M I G R AT I N G
Y O U R W E B S I T E …
6.
7.
8. W H O ’ S E X P E R I E N C E D
T H I S B E F O R E ?
9. D O E S N ’ T I T M A K E Y O U
F E E L L I K E …
13. 4 0 0 - C O D E S
5 0 0 - C O D E S
You stuffed up (client errors)
Your server stuffed up (server errors)
14. 400 Bad Request
401 Unauthorized (RFC 7235)
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
…
15. 400 Bad Request
401 Unauthorized (RFC 7235)
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
…
16. 500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
…
17. 500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
…
D O N ’ T A S K M E .
I ’ M C L U E L E S S ; - )
28. W P _ D E B U G
In wp-config.php:
define( 'WP_DEBUG', false );
Enable debugging:
define( 'WP_DEBUG', true );
29. W P _ D E B U G
Extra statements:
define('WP_DEBUG_LOG', true);
Creates logfile in:
/wp-content/debug.log
30. W P _ D E B U G
Prevent public displaying of errors:
define('WP_DEBUG_DISPLAY', false);
31. W P _ D E B U G
Ideal setup:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
32. A D D I N G W P - C L I
T O Y O U R T O O L K I T
33. W P - C L I
wp plugin list
wp plugin deactivate
wp plugin activate
wp theme list
wp theme deactivate
wp theme activate
wp checksum core
wp checksum plugin (from version 1.5)
34. W P T H E M E L I S T R E S U LT
Parse error: syntax error, unexpected '$z9973449' (T_VARIABLE) in /data/sites/web/somewebsite/
www/wp-includes/post-template.php on line 1
Warning: array_splice() expects parameter 1 to be array, string given in /data/sites/web/somewebsite/
www/wp-content/plugins/akismet/favicon_316779.ico(105) : eval()'d code(165) : eval()'d code(202) :
eval()'d code on line 206
Warning: Invalid argument supplied for foreach() in /data/sites/web/somewebsite/www/wp-content/
plugins/akismet/favicon_316779.ico(105) : eval()'d code(165) : eval()'d code(202) : eval()'d code on
line 207
35. W P T H E M E L I S T R E S U LT
Parse error: syntax error, unexpected '$z9973449' (T_VARIABLE) in /data/sites/web/somewebsite/
www/wp-includes/post-template.php on line 1
Warning: array_splice() expects parameter 1 to be array, string given in /data/sites/web/somewebsite/
www/wp-content/plugins/akismet/favicon_316779.ico(105) :
eval()'d code(165) : eval()'d code(202) : eval()'d code on line 206
Warning: Invalid argument supplied for foreach() in /data/sites/web/somewebsite/www/wp-content/
plugins/akismet/favicon_316779.ico(105) : eval()'d code(165) : eval()'d code(202) : eval()'d code on
line 207
37. S C R I P T _ D E B U G
Forces WordPress to use the “dev” versions of some
core CSS and JavaScript files rather than the minified
versions that are normally loaded. This is useful when you
are testing modifications to any built-in .js or .css files.
define( 'SCRIPT_DEBUG', true );
39. S AV E Q U E R I E S
Force WordPress to store information about queries in a
$wpdb array.
define( 'SAVEQUERIES', true );
40. S AV E Q U E R I E S
Visualize by adding this to footer.php:
if ( current_user_can( 'administrator' ) ) {
global $wpdb;
echo '<pre>';
print_r( $wpdb->queries );
echo '</pre>';
}
42. C O R E
C O N T R O L
• verify crons
• taking manual control of
upgrades
• do HTTP-logging
• Test HTTP-transport-
methods (GET/POST
requests)
https://wordpress.org/plugins/core-control/
43. W P D E B U G
B A R
• Verify queries
• Verify cache
• Verify requests
https://wordpress.org/plugins/debug-bar/
44. T Y P I C A L E R R O R S
A N D H O W T O F I X T H E M
45.
46.
47.
48.
49. Warning: Cannot modify header information - headers already sent by (output started at /data/sites/
web/somewebsite/www/wp-settings.php:84) in /data/sites/web/somewebsite/www/wp-includes/
option.php on line 920
50. Warning: Cannot modify header information - headers already sent by
(output started at /data/sites/web/somewebsite/www/wp-settings.php:84) in /data/sites/web/
somewebsite/www/wp-includes/option.php on line 920
51. H E A D E R S A L R E A D Y S E N T
P O S S I B L E C A U S E S
• Whitespace before <?php or after ?>
• print, echo and other functions producing output
• Raw <html> sections prior <?php code.
57. T H A N K Y O U !
S L I D E S W I L L B E T W E E T E D O N
@ B R E C H T RY C K A E R T
A N D P U B L I S H E D O N
H T T P S : / / B R E C H T RY C K A E R T. C O M