-
Notifications
You must be signed in to change notification settings - Fork 355
Display id instead of error if songs already exists #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
EMREOYUN
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code lacks a check for already uploaded songs. It will work in that way but already uploaded songs still return "Song uploaded" with the already uploaded ID. It may be confusing. You can consider adding "Song already exists with the ID:" but still returning the ID of the already uploaded song, so users will not get confused about it.
| return "-3"; | ||
| $id = $query->fetchColumn(); | ||
| if($id != false){ | ||
| return $id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code lacks the song existence check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a good PHPer, but $id != false should do the trick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no issues with your code.
| if($result == "-4") | ||
| echo "This URL doesn't point to a valid audio file."; | ||
| }elseif($result == "-3") | ||
| echo "This song already exists in our database."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the song exists in the database, it still returns the "song uploaded" message with the ID. It may be confusing. Consider adding "song already exists" but still returning the ID of the already uploaded song.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also thought about this, but the problem is about concept of this "API". It (mainlib function) is expected to return an integer where if > 0 then it is id, if <= 0 assume it failed. We should ask @Cvolton about designing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still removes the capability of the error text "This song already exists in our database." Yes, your code still returns the ID of the song, very well but removing the existing error still be confusable.
I guess we need @Cvolton's opinion on that.
Recreated pull request because of some mess with git since I accidentally did this on
masterbranch