MyBB Community Forums

Full Version: Odd code in functions_warnings.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
function find_warnlevels_to_check(&$query, &$max_expiration_times, &$check_levels)
{
	global $db;

	// we have some warning levels we need to revoke
	$max_expiration_times = array(
		1 => -1,	// Ban
		2 => -1,	// Revoke posting
		3 => -1		// Moderate posting
	);
	$check_levels = array(
		1 => false,	// Ban
		2 => false,	// Revoke posting
		3 => false	// Moderate posting
	);

[...]
}

Whatever is passed as second or third parameter will be overwritten in all cases.
Wat.
Unsure the reasoning behind doing it this way but that is what is expected to happen.
Seems like those parameters are used as "return by reference" variables. Not sure why it was done that way as it looks pretty stupid. However either the doc block needs to be updated (hasn't a good description) or it should be changed to return an array with those variables as we do in other places. Also I'm not sure why "$query" is also passed by reference.
Could potentially break plugins I guess. Probably too late to change it.
Yeah, but then the doc block should be changed. And "$query" doesn't need to be passed as reference as it's not modified inside so it shouldn't break anything.
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/2212

Thanks for contributing to MyBB!

Regards,
The MyBB Group