But... what is a bug?
Examples:
- Page not loading
- Users can't login
- Purchases are not working
The first bug
Why it is important fixing a bug?
Bugs have consequences
Why it is important fixing a bug?
Bugs may:
- Break the User Experience
- Produce financial losses
- Make never-ending projects
- Breach security: data leak, data loss...
What will we see during this session?
- General strategy to deal with bugs
- Bug hunting methodology: detection, bug dealing, tests coverage
- Tools: PHP tools, Continuous integration, Drupal modules, Xdebug
- Quality assurance to minimize bugs
Example
Example
The Strategy
- Detect the bugs as soon as possible
- Fix the bugs with the best solution possible
- Test your site to prevent bugs before releasing
Bug hunting methodology
Detection
Bug hunting methodology
Detection
Both are important!
Bug hunting methodology
Be proactive!
Bug hunting methodology
Detection
Check logs
Bug hunting methodology
Detection
Check logs
Bug hunting methodology
Detection
Check status report
Bug hunting methodology
Detection
Review analytics
Bug hunting methodology
Detection
Smoke tests
Verifies the important features are working in a deployed / released website (or any software).
Bug hunting methodology
Bug dealing
Bug hunting methodology
Bug dealing
Take it easy!
Bug hunting methodology
Bug dealing
Ask for help.
Bug hunting methodology
Bug dealing
- Point out the steps to reproduce the problem.
- Go to the basics
- Think what is the underlying problem that is causing the bug
- Choose the most appropiate solution: choose long term solutions over quick fixes
- Cover the bug with tests
Tools
Tools
Logging Drupal modules
- Syslog
- DB Log
- DBLog filter
Tools
Logging Drupal modules
Watchdog statistics
Tools
Logging Drupal modules
Monolog
Monolog sends your logs to files, sockets, inboxes, databases and various web services.
Tools
Logging Drupal modules
Log entity operations
Tools
Logging Drupal modules
Log entity operations
Tools
Content revisions
Tools
PHP static analysis tools
- PHPStan
- PHP code sniffer (PHPcs)
- PHP mess detector (PHPmd)
Tools
PHP static analysis tools
Example with PHPStan
Tools
Debug the code
Tools
Debug the code
Xdebug
- Available for Netbeans, VS Code and PHPStorm
- Ready to use in DDEV sites with ddev xdebug
Tools
Debug the code
Xdebug
Tools
Debug the code
Tools
Debug the code
Chrome dev tools
Tools
Debug the code
Chrome dev tools
- Use html inspector to find errors in markup
- Read Console to catch possible errors
- Use Network tab to look for information in the requests
- Use Source tab to add breakpoints and start debugging
Quality assurance (QA)
Quality assurance (QA)
Pair code review through Pull / Merge requests
Quality assurance (QA)
Manual review of the new functionalities
Quality assurance (QA)
Try breaking the feature!
Quality assurance (QA)
Static analysis
- PHPStan
- PHP code sniffer (PHPcs)
- PHP mess detector (PHPmd)
Quality assurance (QA)
Tests
- Unit tests: PHPUnit
- Functional tests: Behat, Nightwatch, Cypress
- Regression tests: Cypress / BackstopJS
Quality assurance (QA)
Tests example
Quality assurance (QA)
Continuous integration systems
Continuous integration systems saves you time testing doing it for you.
Quality assurance (QA)
Continuous integration systems
- Gitlab CI
- Jenkins
- Github CI
Can bugs be features?