WordCamp 2019 - Why isn't this working, tips for debugging
July 20, 2019•377 words
@earnjam
think through process first, questions like:
- should I fix this
- is it a high priority
how to report a bug:
- what happened?
- what did you expect?
- what did you do?
- detailed steps
Reports may use language to fill gaps
Basic Troubleshooting strategies
Duplication
- recreate the issue
- lets you know when the issue is actually solved
- provides critical information to bug reports
Keeping a log
- keep record of what you try
- order might matter
- don't repeat yourself DRY
- only make one change at a time
Is it plugged in
- know and confirm the requirements are in place
Bare Bones
- return to most basic state
- deactivate plugins
- change to default theme
Shortening the chain
- evaluate the full path of the workflow
- narrow down the list of possible locations an issue can occur
- repeat
Tools for troubleshooting
Plugins
- Health check and troubleshooting !!!
- official wp.org plugin
- disable all plugins and switch to default theme ONLY FOR CURRENT USER - that's awesome, useful on production site
- User Switching (alt to SU)
- multisite compatible
- WP Crontrol !!!
- see list of registered cron tasks
- add remove tasks directly from the dashboard
- run a scheduled task manually
- Query Monitor !!!
- so many good features
Methods
Logging
logging v debugging - logging is lifecycle data, debugging is more about breakpoints or moment in time
- most basic is outputting
- apache/nginx error log and access log
- PHP error log
- browser console
Debuggers
- breakpoints
- inspect assigned variables
- PHP - Xdebug
- Javascript - browser
- integrate with IDE
Demos
WP-Cron test with error_log() which just writes to the error log, nice
Query Monitor is amazing, absolutely amazing
monitors HTTP API, but mostly using raw PHP so maybe change?
shows value of WP conditionals
Breakpoints/vscode/Xdebug how does that work
Use JS debugger; command more
XDebug environment makes a big difference, "local by flywheel" or "VVV" are good ones, come with XDebug installed
Extension for Chrome called Debugger for Chrome hooks into VS Code (not great with webpack)