Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Won't Fix
-
3.0.10
-
None
Description
If you have approved topic with only 1 approved post (topic starting post) and unapproved replies (one or more), if you try to delete 1st post from the topic, you get an error like this:
General Error
SQL ERROR [ mysqli ]BIGINT UNSIGNED value is out of range in '(`3010`.`phpbb_topics`.`topic_replies` - 1)' [1690]
SQL
UPDATE phpbb_topics SET topic_poster = 54, topic_first_post_id = 12, topic_first_poster_colour = '', topic_first_poster_name = '111', topic_time = 1330229561, topic_replies_real = topic_replies_real - 1, topic_replies = topic_replies - 1, topic_attachment = 0 WHERE topic_id = 4
BACKTRACE
FILE: [ROOT]/includes/db/mysqli.php
LINE: 182
CALL: dbal->sql_error()FILE: [ROOT]/includes/functions_posting.php
LINE: 1589
CALL: dbal_mysqli->sql_query()FILE: [ROOT]/posting.php
LINE: 1582
CALL: delete_post()FILE: [ROOT]/posting.php
LINE: 314
CALL: handle_post_delete()
This is because function delete_post() (includes/functions_postimg.php) does not handle such case properly:
// Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply"
|
$sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
|
Thus, if the post being deleted is approved, it just tries to assign a negative value (0 - 1) to the topic_replies field.