Index: branches/5.2.x/units/helpers/post_helper.php =================================================================== diff -u -N -r15140 -r15249 --- branches/5.2.x/units/helpers/post_helper.php (.../post_helper.php) (revision 15140) +++ branches/5.2.x/units/helpers/post_helper.php (.../post_helper.php) (revision 15249) @@ -1,6 +1,6 @@ Conn->doUpdate($fields_hash, $table_name, $id_field . ' IN (' . implode(',', $parent_categories) . ')'); } - /** + /** * Sets today posts count & today date for topic * * @param kCatDBItem $object + * @param int $post_date * @param int $increment_by + * @return bool */ function updateTodayPostsCount(&$object, $post_date, $increment_by = 1) { Index: branches/5.2.x/units/posts/post_eh.php =================================================================== diff -u -N -r15148 -r15249 --- branches/5.2.x/units/posts/post_eh.php (.../post_eh.php) (revision 15148) +++ branches/5.2.x/units/posts/post_eh.php (.../post_eh.php) (revision 15249) @@ -1,6 +1,6 @@ GetDBField('TopicId'); if ( !$topic_id ) { - // deleting non-existing post + // deleting post from non-existing topic return; } @@ -361,6 +361,11 @@ $main_object->Load($topic_id); + if ( !$main_object->isLoaded() ) { + // this is topic deletion proccess, when all it's posts are deleted too + return; + } + $post_helper->updateTodayPostsCount($main_object, $object->GetDBField('CreatedOn'), -1); if ( $main_object->GetDBField('LastPostId') == $object->GetID() ) {