MyBB Community Forums

Full Version: Invalid reputation counters
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I discovered small bug in reputation counters in member profile view.

In default, everything is ok like this:

[attachment=33517]

But... if we change thousands separator to space (" ") used in example in Poland, counters are totally buggy:

[attachment=33518]


I looked into the code and problem is that MyBB:
- get SUM of all reputation
- get SUM of reputation from posts
- format reputation from posts
- get reputation from members by subtract posts from sum

From reputation.php:


	// Figure out how many reps have come from posts / 'general'
	// Posts
	$query = $db->simple_select("reputation", "COUNT(rid) AS rep_posts", "uid = '".$user['uid']."' AND pid > 0");
	$rep_post_count = $db->fetch_field($query, "rep_posts");
	$rep_posts = my_number_format($rep_post_count);
    
	// General
	// We count how many reps in total, then subtract the reps from posts
	$rep_members = my_number_format($total_reputation - $rep_posts);

It's bug, because formatted text should not be used in subtraction (php use only first digit).

Solution: 
Use $rep_post_count instead of $rep_posts in last line.
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/1897

Thanks for contributing to MyBB!

Regards,
The MyBB Group