There is this source code on GitHub (a PHP class, around 200 lines of code) distributed under GPL license which has some bugs and is not useful to me unless those bugs are fixed. If I fix those bugs, can I use the new code in my product commercially?
Yes, so long as the commercial product is released under the GNU GPL.
Assuming the GNU GPL v3 for clarity's sake (the same conclusion would be reached for the GPL v2, just the wording is different):
- By fixing the bugs, you are producing a "work based on the Program". If distributed, this modified work must be licensed under the GPL.
- You can then incorporate the modified work into your commercial product, and then distribute the commercial product under the GPL in accordance with any of the options in section 6 of the GPL - note that all these require you to release the full source (not just that of the modified code) of your commercial product.