Skip to content

Commit

Permalink
#956 Fix bug during update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick committed Oct 31, 2014
1 parent 161a731 commit 69de7d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,13 @@ function update_forum($forum_id) {

$num_posts = $num_posts + $num_topics; // $num_posts is only the sum of all replies (we have to add the topic posts)

$result = $db->query('SELECT last_post, last_post_id, last_poster, last_poster_id, subject FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id.' AND moved_to IS NULL ORDER BY last_post DESC LIMIT 1') or error('Unable to fetch last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT last_post, last_post_id, last_poster_id FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id.' AND moved_to IS NULL ORDER BY last_post DESC LIMIT 1') or error('Unable to fetch last_post/last_post_id', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result)) { // There are topics in the forum
list($last_post, $last_post_id, $last_poster, $last_poster_id, $last_topic) = $db->fetch_row($result);
list($last_post, $last_post_id, $last_poster_id) = $db->fetch_row($result);

$db->query('UPDATE '.$db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post='.$last_post.', last_post_id='.$last_post_id.', last_poster_id=\''.$db->escape($last_poster_id).'\', WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error());
$db->query('UPDATE '.$db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post='.$last_post.', last_post_id='.$last_post_id.', last_poster_id=\''.$db->escape($last_poster_id).'\' WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id', __FILE__, __LINE__, $db->error());
} else // There are no topics
$db->query('UPDATE '.$db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post=NULL, last_post_id=NULL, last_poster_id=NULL, WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster/last_topic', __FILE__, __LINE__, $db->error());
$db->query('UPDATE '.$db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post=NULL, last_post_id=NULL, last_poster_id=NULL WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_topic', __FILE__, __LINE__, $db->error());
}


Expand Down
2 changes: 1 addition & 1 deletion include/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Version {
const FORUM_VERSION = '0.0.2';

// The Luna Core version
const FORUM_CORE_VERSION = '0.0.3224';
const FORUM_CORE_VERSION = '0.0.3225';

// The database version number, every change in the database requires this number to go one up
const FORUM_DB_VERSION = 84.70;
Expand Down

0 comments on commit 69de7d1

Please sign in to comment.