Finding and Fixing Bugs in Software
Unfortunately, despite our best efforts, computer software is incredibly brittle (as opposed to being flexible). That means that a small change somewhere can totally break something and prevent anything from working at all.
So when something breaks, it can be easy to panic and imagine something terrible has happened, but often it's something fairly small that's easy to fix.
Having had to fix bugs and issues for many, many years there tends to be a predictable procedure to go through each time which usually ends in finding the root cause of the issue:
- Cause the error to happen, and pay attention to what you see.
- If there's an error message, Google it. Often this will be enough to find a solution.
- If there's no error message, try and find one by checking the error logs. In OpenCart these will be in either /system/logs/error.log or in /error_log or /admin/error_log. Googling this will often get to a solution. If that solution happens to be on Stack Overflow with lots of upvotes then your problem is probably solved.
If there was no error, then it gets a bit harder, we have to identify where the program is failing and you will need to be able to read some code but he's a bit of an overview of the process that a developer may go through:
- Based on the URL in the address bar, it may be possible to work out what file is running. In OpenCart, the route URL variable will tell you which "controller" file to start from. If this variable isn't there you could try temporarily disabling SEO URLs to show it.
- Start at the very top of the first function to run (usually called index) and print some text and then exit with the "die" function.
- In most cases something is output, but if not you may have to do this process from the index.php in the web root.
- Keep moving the print and die commands down and refreshing the page until they are not output.
- The line before is probably where the error is happening. You'll need to do some tests here to find out what's going wrong but at least you can be fairly sure the error is here.
And if all else fails, get in touch with a friendly PHP developer!blog comments powered by Disqus