Icy Phoenix


Post new topic  Reply to topic 
Page 1 of 1
Reply with quote Download Post
Post [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.
Code: [Download] [Hide]
  1. /modcp.php 

around line
Code: [Download] [Hide]
  1. 360 

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

Code: [Download] [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.

Edited by Informpro, Tue 19 Jul, 2011 00:13: I dunno if I was drunk, but it looks like.
InformproSend private message  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
Post new topic  Reply to topic  Page 1 of 1

Display posts from previous:    

HideWas this topic useful?

Link this topic

Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events