Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

WordCamp Antwerp - 3/3/2018 - Debugging WordPress by Brecht Ryckaert

248 views

Published on

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.

Published in: Internet
  • Be the first to comment

  • Be the first to like this

WordCamp Antwerp - 3/3/2018 - Debugging WordPress by Brecht Ryckaert

  1. 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. 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. 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. 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. 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. 6. 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 ?
  7. 7. D O E S N ’ T I T M A K E Y O U F E E L L I K E …
  8. 8. T W O K I N D S O F 
 E R R O R C O D E S …
  9. 9. 4 0 0 - C O D E S 
 5 0 0 - C O D E S
  10. 10. 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)
  11. 11. 400 Bad Request 401 Unauthorized (RFC 7235) 402 Payment Required 403 Forbidden 404 Not Found 405 Method Not Allowed …
  12. 12. 400 Bad Request 401 Unauthorized (RFC 7235) 402 Payment Required 403 Forbidden 404 Not Found 405 Method Not Allowed …
  13. 13. 500 Internal Server Error 501 Not Implemented 502 Bad Gateway 503 Service Unavailable 504 Gateway Timeout …
  14. 14. 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 ; - )
  15. 15. H O W T O D E B U G ?
  16. 16. - S E R V E R L O G S 
 - W P _ D E B U G 
 - W P - C L I - S C R I P T _ D E B U G - S AV E Q U E R I E S - P L U G I N S
  17. 17. S E R V E R L O G S
  18. 18. T Y P E S O F E R R O R S I N T H E L O G S • FATAL ERROR • WARNING/NOTICE • LIMIT-RELATED
  19. 19. [Sat Feb 10 02:05:22.490389 2018] [error] [pid 5740] mod_proxy_fcgi.c(954): (70007)The timeout specified has expired: [client 141.101.77.82:32531] AH01075: Error dispatching request to : (polling) [Sat Feb 10 03:42:55.356581 2018] [error] [pid 34419] mod_authz_core.c(873): [client 176.62.169.28:27736] AH01630: client denied by server configuration: /data/sites/web/somewebsite.com/.user.ini [Sat Feb 10 10:50:24.838424 2018] [error] [pid 41100] mod_proxy_fcgi.c(954): (70007)The timeout specified has expired: [client 162.158.111.75:24677] AH01075: Error dispatching request to : (polling) [Sat Feb 10 10:50:36.741167 2018] [error] [pid 48392] apache2_util.c(271): [client 172.68.65.254:35087] [client 172.68.65.254] ModSecurity: Access denied with code 403 (phase 2). Matched phrase "SemrushBot" at REQUEST_HEADERS:User-Agent. [file "/usr/local/httpd/conf/modsecurity-crs/activated-rules/modsecurity_crs_35_bad_robots.conf"] [line "20"] [id "990002"] [rev "2"] [msg "Request Indicates a Security Scanner Scanned the Site"] [data "mozilla/5.0 (compatible; semrushb ot/1.2~bl; +http://www.semrush.com/bot.html)"] [severity "CRITICAL"] [ver "OWASP_CRS/2.2.9"] [maturity "9"] [accuracy "9"] [tag "OWASP_CRS/AUTOMATION/SECURITY_SCANNER"] [tag "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A7"] [tag "PCI/6.5.10"] [h ostname “www.somewebsite.com”] [uri "/tag/romeinen/"] [unique_id "Wn7AbE4XLPnYH7fIxTBlGwAAAcY"]
  20. 20. [Sat Feb 10 02:05:22.490389 2018] [error] [pid 5740] mod_proxy_fcgi.c(954): (70007)The timeout specified has expired: [client 141.101.77.82:32531] AH01075: Error dispatching request to : (polling) [Sat Feb 10 03:42:55.356581 2018] [error] [pid 34419] mod_authz_core.c(873): [client 176.62.169.28:27736] AH01630: client denied by server configuration:/data/sites/web/somewebsite.com/.user.ini [Sat Feb 10 10:50:24.838424 2018] [error] [pid 41100] mod_proxy_fcgi.c(954): (70007)The timeout specified has expired: [client 162.158.111.75:24677] AH01075: Error dispatching request to : (polling) [Sat Feb 10 10:50:36.741167 2018] [error] [pid 48392] apache2_util.c(271): [client 172.68.65.254:35087] [client 172.68.65.254] ModSecurity: Access denied with code 403 (phase 2). Matched phrase "SemrushBot" at REQUEST_HEADERS:User-Agent. [file "/usr/local/httpd/conf/modsecurity-crs/activated-rules/modsecurity_crs_35_bad_robots.conf"] [line "20"] [id "990002"] [rev "2"] [msg "Request Indicates a Security Scanner Scanned the Site"] [data "mozilla/5.0 (compatible; semrushb ot/1.2~bl; +http://www.semrush.com/bot.html)"] [severity "CRITICAL"] [ver "OWASP_CRS/2.2.9"] [maturity "9"] [accuracy "9"] [tag "OWASP_CRS/AUTOMATION/SECURITY_SCANNER"] [tag "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A7"] [tag "PCI/6.5.10"] [h ostname “www.somewebsite.com”] [uri "/tag/romeinen/"] [unique_id "Wn7AbE4XLPnYH7fIxTBlGwAAAcY"]
  21. 21. [Sat Feb 10 02:05:22.490389 2018] [error] [pid 5740] mod_proxy_fcgi.c(954): (70007)The timeout specified has expired: [client 141.101.77.82:32531] AH01075: Error dispatching request to : (polling) [Sat Feb 10 03:42:55.356581 2018] [error] [pid 34419] mod_authz_core.c(873): [client 176.62.169.28:27736] AH01630: client denied by server configuration: /data/sites/web/somewebsite.com/.user.ini [Sat Feb 10 10:50:24.838424 2018] [error] [pid 41100] mod_proxy_fcgi.c(954): (70007)The timeout specified has expired: [client 162.158.111.75:24677] AH01075: Error dispatching request to : (polling) [Sat Feb 10 10:50:36.741167 2018] [error] [pid 48392] apache2_util.c(271): [client 172.68.65.254:35087] [client 172.68.65.254] ModSecurity: Access denied with code 403 (phase 2). Matched phrase "SemrushBot" at REQUEST_HEADERS:User-Agent. [file "/usr/local/httpd/conf/modsecurity-crs/activated-rules/modsecurity_crs_35_bad_robots.conf"] [line "20"] [id "990002"] [rev "2"] [msg "Request Indicates a Security Scanner Scanned the Site"] [data "mozilla/5.0 (compatible; semrushb ot/1.2~bl; +http://www.semrush.com/bot.html)"] [severity "CRITICAL"] [ver "OWASP_CRS/2.2.9"] [maturity "9"] [accuracy "9"] [tag "OWASP_CRS/AUTOMATION/SECURITY_SCANNER"] [tag "WASCTC/WASC-21"] [tag "OWASP_TOP_10/A7"] [tag "PCI/6.5.10"] [h ostname “www.somewebsite.com”] [uri "/tag/romeinen/"] [unique_id "Wn7AbE4XLPnYH7fIxTBlGwAAAcY"]
  22. 22. Tue Jan 16 15:10:55.316779 2018] [error] [pid 6002] mod_proxy_fcgi.c(848): [client 178.119.78.83:63467] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method SitePress::is_display_as_translated_taxonomy() in /data/sites/web/somewebsite/ www/wp-content/plugins/woocommerce-multilingual/inc/class-wcml-dependencies.php:365nStack trace:n#0 /data/sites/web/somewebsite/www/wp-includes/class-wp-hook.php(286): WCML_Dependencies->check_wpml_config('')n#1 /data/sites/web/somewebsite/www/wp-includes/ class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)n#2 /data/sites/web/somewebsite/ www/wp-includes/plugin.php(453): WP_Hook->do_action(Array)n#3 /data/sites/web/somewebsite/ www/wp-settings.php(450): do_action('init')n#4 /data/sites/web/somewebsite/www/wp- config.php(83): require_once('/data/sites/web...')n#5 /data/sites/web/somewebsite/www/wp- load.php(37): require_once('/data/sites/web...')n#6 /data/sites/web/somewebsite/www/wp-admin/ admin-ajax.php(22): require_once('/data/sites/web...')n#7 {main}n  thrown in /data/sites/web/ somewebsite/www/wp-content/plugins/woocommerce-multilingua...n'
  23. 23. Tue Jan 16 15:10:55.316779 2018] [error] [pid 6002] mod_proxy_fcgi.c(848): [client 178.119.78.83:63467] AH01071: Got error 'PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method SitePress::is_display_as_translated_taxonomy() in /data/sites/web/ somewebsite/www/wp-content/plugins/woocommerce-multilingual/inc/class-wcml-dependencies.php: 365nStack trace:n#0 /data/sites/web/somewebsite/www/wp-includes/class-wp-hook.php(286): WCML_Dependencies->check_wpml_config('')n#1 /data/sites/web/somewebsite/www/wp-includes/ class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)n#2 /data/sites/web/somewebsite/ www/wp-includes/plugin.php(453): WP_Hook->do_action(Array)n#3 /data/sites/web/somewebsite/ www/wp-settings.php(450): do_action('init')n#4 /data/sites/web/somewebsite/www/wp- config.php(83): require_once('/data/sites/web...')n#5 /data/sites/web/somewebsite/www/wp- load.php(37): require_once('/data/sites/web...')n#6 /data/sites/web/somewebsite/www/wp-admin/ admin-ajax.php(22): require_once('/data/sites/web...')n#7 {main}n  thrown in /data/sites/web/ somewebsite/www/wp-content/plugins/woocommerce-multilingua...n'
  24. 24. T H E P O W E R O F W P _ D E B U G
  25. 25. W P _ D E B U G In wp-config.php: define( 'WP_DEBUG', false ); Enable debugging: define( 'WP_DEBUG', true );
  26. 26. W P _ D E B U G Extra statements: define('WP_DEBUG_LOG', true); Creates logfile in: /wp-content/debug.log
  27. 27. W P _ D E B U G Prevent public displaying of errors: define('WP_DEBUG_DISPLAY', false);
  28. 28. W P _ D E B U G Ideal setup: define('WP_DEBUG', true);
 define('WP_DEBUG_LOG', true);
 define('WP_DEBUG_DISPLAY', false);
  29. 29. A D D I N G W P - C L I 
 T O Y O U R T O O L K I T
  30. 30. 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)
  31. 31. 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
  32. 32. 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
  33. 33. S C R I P T _ D E B U G
  34. 34. 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 );

  35. 35. S AV E Q U E R I E S
  36. 36. S AV E Q U E R I E S Force WordPress to store information about queries in a $wpdb array. define( 'SAVEQUERIES', true );

  37. 37. 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>'; }

  38. 38. U S E F U L P L U G I N S
  39. 39. 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/
  40. 40. W P D E B U G B A R • Verify queries • Verify cache • Verify requests https://wordpress.org/plugins/debug-bar/
  41. 41. 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
  42. 42. 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
  43. 43. 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
  44. 44. 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.
  45. 45. B A C K T O T H E 
 ( N E A R B Y ) F U T U R E
  46. 46. T I D E https://make.wordpress.org/tide/
  47. 47. W H AT C A N Y O U D O ?
  48. 48. W H AT C A N Y O U D O ? Report bugs and issues to the developer
  49. 49. Q U E S T I O N S ?
  50. 50. 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

×