[workaround] Bad Behavior With Postcount »  Show posts from    to     

Icy Phoenix


Old Support Topics - [workaround] Bad Behavior With Postcount



Informpro [ Tue 29 Mar, 2011 22:01 ]
Post subject: [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.
file
Code: [Hide]
  1. /modcp.php 

around line
Code: [Hide]
  1. 360 

default code
Code: [Hide]
  1. <? $count_sql[] = "UPDATE " . USERS_TABLE . " SET user_posts = users_posts - " . $row['posts'] . " 
  2. WHERE user_id = " . $row['poster_id']; 

code
Code: [Hide]
  1. //set the new post count to [actual]-[delete] IF [actual] gt delete. 
  2. $count_sql[] = "UPDATE " . USERS_TABLE . " 
  3. SET user_posts = CASE 
  4. WHEN user_posts >= " . $row['posts'] . " THEN user_posts - " . $row['posts'] . " 
  5. ELSE 0 
  6. END 
  7. WHERE user_id = " . $row['poster_id']; 
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.




Powered by Icy Phoenix