Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-10673

General error when deleting only approved post in the topic having unapproved replies

    XMLWordPrintable

Details

    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.

      Attachments

        Activity

          People

            CHItA CHItA
            rxu rxu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: