bartervg / barter.vg

Track and hold discussion on Barter.vg bugs, enhancements, and other issues
https://barter.vg
MIT License
20 stars 4 forks source link

Wrong number of items tagged is shown when you update an existing trade tag with a new integer tag value from your tradables list #94

Closed Tecfan closed 4 years ago

Tecfan commented 4 years ago

Describe the bug

When you update the tags on your games in your tradable list and press "Tag", a message appears on the top of the page. For example, if you add "userfield" to a game, with an integer tag value of "10", it will show you this message: "Updated 1 item tagged".

If you then were to update the integer tag value from "10" to "15", still only having this one item selected, you will get the following message: "Updated 2 items tagged". This is wrong – only 1 item was tagged.

If you update the integer tag value of 5 items at the same time, it will then tell you that you updated 10 items (it doubles).

This is true for all trading tags when you use the integer tag value field. The "integer tag value" field can also be empty for the bug to appear. For example, if you add the tag "combined" with no integer value, and then update it to any number in a second action, you will still see "2 items tagged", when you only tagged 1 item.

See screenshot for more context. Only 1 item is selected, but the system claims that it updated 2 items. image

bartervg commented 4 years ago

This appears to be the cause of the bug https://www.php.net/manual/en/mysqli.affected-rows.php#102523

+1: a row was inserted +2: a row was updated

bartervg commented 4 years ago

previously: items_tagged += affected_rows currently: if(affected_rows > 0){ items_items += 1 }

bartervg commented 4 years ago

image image

upon update of tag image image

It looks to be fixed although it is likely that I used ON DUPLICATE KEY UPDATE and += affected_rows in other areas of the site.