Skip to content

Conversation

@Galster-dev
Copy link
Contributor

Recreated pull request because of some mess with git since I accidentally did this on master branch

Copy link
Contributor

@EMREOYUN EMREOYUN left a 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;
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.";
Copy link
Contributor

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.

Copy link
Contributor Author

@Galster-dev Galster-dev Jul 2, 2022

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

Copy link
Contributor

@EMREOYUN EMREOYUN Jul 3, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants