Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fluxbb 1.4 #31

Merged
merged 1 commit into from

3 participants

@oldskool
Collaborator

No description provided.

@oldskool oldskool merged commit 73de7c4 into fluxbb:fluxbb-1.4
@franzliedke

I really do wonder why they didn't do it this way originally. Maybe to have an extra layer of synchronization, as the database schema is not properly normalized? But then, really, what could happen that we introduce inconsistencies in the database, eh?

Collaborator

The change was made when developing 1.2:

http://punbb.informer.com/forums/post/20715/#p20715

Rewrote topic reply counting code to be less error prone. The reply count for a topic is now re-calculated whenever a post is added or removed.

But making the UPDATE query relative to the current value (as this change does) is actually the correct way to do things, assuming every other script similarly keeps data in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 30, 2012
  1. @oldskool
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 5 deletions.
  1. +1 −5 post.php
View
6 post.php
@@ -191,12 +191,8 @@
$new_pid = $db->insert_id();
}
- // Count number of replies in the topic
- $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'posts WHERE topic_id='.$tid) or error('Unable to fetch post count for topic', __FILE__, __LINE__, $db->error());
- $num_replies = $db->result($result, 0) - 1;
-
// Update topic
- $db->query('UPDATE '.$db->prefix.'topics SET num_replies='.$num_replies.', last_post='.$now.', last_post_id='.$new_pid.', last_poster=\''.$db->escape($username).'\' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
+ $db->query('UPDATE '.$db->prefix.'topics SET num_replies=num_replies+1, last_post='.$now.', last_post_id='.$new_pid.', last_poster=\''.$db->escape($username).'\' WHERE id='.$tid) or error('Unable to update topic', __FILE__, __LINE__, $db->error());
update_search_index('post', $new_pid, $message);
Something went wrong with that request. Please try again.