Skip to content

Display id instead of error if songs already exists - #857

Open
Galster-dev wants to merge 1 commit into
Cvolton:masterfrom
Galster-dev:features/song_id
Open

Display id instead of error if songs already exists#857
Galster-dev wants to merge 1 commit into
Cvolton:masterfrom
Galster-dev:features/song_id

Conversation

@Galster-dev

Copy link
Copy Markdown
Contributor

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

@EMREOYUN EMREOYUN left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread incl/lib/mainLib.php
return "-3";
$id = $query->fetchColumn();
if($id != false){
return $id;

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread tools/songAdd.php
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
Copy Markdown
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.

@Galster-dev Galster-dev Jul 2, 2022

Copy link
Copy Markdown
Contributor Author

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

@EMREOYUN EMREOYUN Jul 3, 2022

Copy link
Copy Markdown
Contributor

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