Skip to content
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

Unapproving topic in Recycle bin causes error or negative numbers #7777

Open
jdarwood007 opened this issue Jun 18, 2023 · 1 comment
Open

Comments

@jdarwood007
Copy link
Member

Description

If you try to unapprove a topic in the recycle bin a error can occur. On some forums, due to database types, it can cause a negative number as well.

Steps to reproduce

  1. Create topic
  2. Delete topic (Ensuring Recycle Bin feature enabled)
  3. Unapprove topic

In my testing:

BIGINT UNSIGNED value is out of range in '(`smf21git`.`smf_boards`.`num_posts` + -(1))'
File: /Sources/Subs-Post.php
Line: 2571


UPDATE smf_boards
SET num_posts = num_posts + -1, unapproved_posts = unapproved_posts + 1,
num_topics = num_topics + -1, unapproved_topics = unapproved_topics + 1
WHERE id_board = 15

On other boards, it seems to allow it to go to -1

Environment (complete as necessary)

  • Version/Git revision: 2.1.4
  • Database Type: Mysql
  • Database Version: 8.0
  • PHP Version: 8.1

Additional information/references

@jdarwood007
Copy link
Member Author

jdarwood007 commented Jun 18, 2023

This might be better to set the query to do something like:

num_topics = MAX(0, num_topics + -1), unapproved_topics = MAX(0, unapproved_topics + 1) ```

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

No branches or pull requests

2 participants