Fix for #15: Fixed bug for editSong throwing error when song_id doesn't exist #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For #15:
If a song doesn't exist in the database, the application will throw a PHP error. To fix this, I check for rowCount() of the getSong method, and, if it's zero (i.e. that song_id doesn't exist in the database), I return false. I then check the status of that in the SongsController editSong method, and display either the edit page, or the error page depending.
This can be changed by the user in a variety of ways.
Understanding this page probably doesn't matter much to users of this framework, a bug is a bug.
@panique this is a rudimentary solution, and certainly not a hyper elegant one. If there's a better solution for it, please feel free to change it. This uses the error solution from PR #41, to display the error page in-place, instead of redirecting to the error page; this can be changed easily, however.