MyBB Community Forums

Full Version: maxwarningsday Bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
https://community.mybb.com/thread-214294.html

This bug is similar to that one.



	// Check we haven't exceeded the maximum number of warnings per day
	if($mybb->usergroup['maxwarningsday'] != 0)
	{
		$timecut = TIME_NOW-60*60*24;
		$query = $db->simple_select("warnings", "COUNT(wid) AS given_today", "issuedby='{$mybb->user['uid']}' AND dateline>'$timecut'");
		$given_today = $db->fetch_field($query, "given_today");
		if($given_today >= $mybb->usergroup['maxwarningsday'])
		{
			error($lang->sprintf($lang->warnings_reached_max_warnings_day, $mybb->usergroup['maxwarningsday']));
		}
	}

Example Bug:

Main Usergroup : Cannot warn users / maxwarningsperday 0
Secondary group: Can warn users / maxwarningsperday 3

User can give unlimited warnings.

Please confirm and fix.

EDIT: Btw I'm going to make a simple suggestion that eliminates a setting and could make things like this less buggy.

Remove the canwarnusers setting and use maxwarningsday with -1 as unlimited, 0 as cannot warn, and anything over 0 as the actual limit. In this way you simplify the code and remove a setting but achieve the same results. MyBB continues to use 0 as unlimited and I think that's a poor choice. Consider a better implementation.
I agree with you.
Quote:Remove the canwarnusers setting and use maxwarningsday with -1 as unlimited, 0 as cannot warn, and anything over 0 as the actual limit. In this way you simplify the code and remove a setting but achieve the same results. MyBB continues to use 0 as unlimited and I think that's a poor choice. Consider a better implementation.

Agreed for sure, not sure however how to handle that on upgrade though - should we convert existing settings of 0 to -1 or just hope people read the release blog post (people don't usually seem to do so...).
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/3037

Thanks for contributing to MyBB!

Regards,
The MyBB Group
Quote:Agreed for sure, not sure however how to handle that on upgrade though - should we convert existing settings of 0 to -1 or just hope people read the release blog post (people don't usually seem to do so...).

Convert existing setting of 0 to -1 if the canwarnusers is 1. Otherwise it's the same. If canwarnusers is 0 then just make sure maxwarningsperday is also 0. You could do this for a few settings including the signature permission bug.
Excuse me, but we just thought a lot here.
I am not against merging 2 settings to 1 or optimization things but then a lot of interdependent settings in ACP act that way. To optimize all those settings is another exercise.

For now, simple and sweet : Omit 'maxwarningsday' from $groupzerogreater to capture grater value instead of 0.
PR generated. Thanks.