diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-08-16 17:07:31 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-09-26 01:14:31 +0200 |
commit | a7cf62decf4e4e4d2c73ad7b4f91d40c681784fb (patch) | |
tree | e00394f418c193a4f2c949d3386e8e03ac064429 | |
parent | f8d6f0ef08f96c55c6934e60349aa5ff5ea00528 (diff) | |
download | forums-a7cf62decf4e4e4d2c73ad7b4f91d40c681784fb.tar forums-a7cf62decf4e4e4d2c73ad7b4f91d40c681784fb.tar.gz forums-a7cf62decf4e4e4d2c73ad7b4f91d40c681784fb.tar.bz2 forums-a7cf62decf4e4e4d2c73ad7b4f91d40c681784fb.tar.xz forums-a7cf62decf4e4e4d2c73ad7b4f91d40c681784fb.zip |
[ticket/11691] Fix some more problems with softdelete update
* wrong order of arguments on sql_query_limit
* avoid "BIGINT UNSIGNED value is out of range" errors
* increase limit for the loop
PHPBB3-11691
-rw-r--r-- | phpBB/phpbb/db/migration/data/v310/softdelete_p1.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php index 27bf5b6a57..cdf61569b8 100644 --- a/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php +++ b/phpBB/phpbb/db/migration/data/v310/softdelete_p1.php @@ -125,15 +125,20 @@ class softdelete_p1 extends \phpbb\db\migration\migration public function update_topics_post_counts() { + /* + * Using sql_case here, to avoid "BIGINT UNSIGNED value is out of range" errors. + * As we update all topics in 2 queries, one broken topic would stop the conversion + * for all topics and the surpressed error will cause the admin to not even notice it. + */ $sql = 'UPDATE ' . $this->table_prefix . 'topics SET topic_posts_approved = topic_replies + 1, - topic_posts_unapproved = topic_replies_real - topic_replies + topic_posts_unapproved = ' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . ' WHERE topic_visibility = ' . ITEM_APPROVED; $this->sql_query($sql); $sql = 'UPDATE ' . $this->table_prefix . 'topics SET topic_posts_approved = 0, - topic_posts_unapproved = (topic_replies_real - topic_replies) + 1 + topic_posts_unapproved = (' . $this->db->sql_case('topic_replies_real > topic_replies', 'topic_replies_real - topic_replies', '0') . ') + 1 WHERE topic_visibility = ' . ITEM_UNAPPROVED; $this->sql_query($sql); } @@ -141,13 +146,13 @@ class softdelete_p1 extends \phpbb\db\migration\migration public function update_forums_topic_and_post_counts($start) { $start = (int) $start; - $limit = 2; + $limit = 10; $i = 0; $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts_approved) AS sum_posts_approved, SUM(topic_posts_unapproved) AS sum_posts_unapproved FROM ' . $this->table_prefix . 'topics GROUP BY forum_id, topic_visibility'; - $result = $this->db->sql_query_limit($sql, $start, $limit); + $result = $this->db->sql_query_limit($sql, $limit, $start); $update_forums = array(); while ($row = $this->db->sql_fetchrow($result)) |