https://www.icyphoenix.com/viewtopic.php?f=35&t=7750&p=52173#p52173
-----------------------------------
Informpro
Tue 29 Mar, 2011 22:01

[workaround] Bad Behavior With Postcount
-----------------------------------
Hi ! (4th)

Just yesterday I've got a little bug. My own postcount was 0 but I had 2 posts ... And I don't even changed anything !
So I created a littke workaround in modcp.
[b]file[/b][code]/modcp.php[/code]
[b]around line[/b][code]360[/code]
[b]default code[/b][code=php]<? $count_sql[] = "UPDATE " . USERS_TABLE . " SET user_posts = users_posts - " . $row['posts'] . "
                    WHERE user_id = " . $row['poster_id'];[/code]
[b]code[/b][code]                //set the new post count to [actual]-[delete] IF [actual] gt delete.
				$count_sql[] = "UPDATE " . USERS_TABLE . "
                    SET user_posts = CASE
                        WHEN user_posts >= " . $row['posts'] . " THEN user_posts - " . $row['posts'] . "
                        ELSE 0
                    END
					WHERE user_id = " . $row['poster_id'];[/code]Two cases :
1) the author has more posts (in his postscount) than he's trying to delete. => default behavior
2) the author is trying to delete MORE posts than he have in his postscount. => set to 0 (because it would result in an negative number, and the field is unsigned (unsigned => does not allow negative numbers)).

Have a nice day.


