MyBB Community Forums

Full Version: Stats Cache Builder Bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If forum not have any threads, stats cache builder gives this error:
1366 - Incorrect integer value: '' for column 'numthreads' at row 1
Query:
REPLACE INTO mybb_stats SET dateline=1442869200,numusers='8',numthreads='',numposts=''
Though I've never seen that bug before I can confirm that it may happen:

https://github.com/mybb/mybb/blob/261b0f...2432-L2439

	if(!empty($new_stats))
	{
		if(is_array($stats))
		{
			$stats = array_merge($stats, $new_stats); // Overwrite changed values
		}
		else
		{
			$stats = $new_stats;
		}
	}
	// Update stats row for today in the database
	$todays_stats = array(
		"dateline" => mktime(0, 0, 0, date("m"), date("j"), date("Y")),
		"numusers" => $stats['numusers'],
		"numthreads" => $stats['numthreads'],
		"numposts" => $stats['numposts']
	);
	$db->replace_query("stats", $todays_stats, "dateline");

If the one stat is changed (in this case numusers) but the others aren't set at all they're casted as empty string which throws an error. A simple integer casting should fix this.
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/2209

Thanks for contributing to MyBB!

Regards,
The MyBB Group