MyBB Community Forums

Full Version: [F] Only the first active promotion is processed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In file inc/tasks/promotions.php, version:
* $Id: promotions.php 3883 2008-06-05 00:38:28Z Tikitiki $

There is a bug, that causes all but the first active user group promotion to be processed.

Essential parts of the code:

17:	$query = $db->simple_select("promotions", "*", "enabled = '1'");
18:	while($promotion = $db->fetch_array($query))
19:	{
...:		<find the userid's matching this promotion rule>
93:		$query = $db->simple_select("users", "uid,{$usergroup_select}", $sql_where);
94:		while($user = $db->fetch_array($query))
95:		{
...:			<do the promotion>
139:		}
...
153:	}

The problem here is, that $query variable gets overwritten in the inner loop, preventing the fetch_array($query) in the outer loop from returning the next promotion rule to be processed. The $query variable in the inner loop must thus be changed into something else, like $query2.

Solution: change the following 2 lines of code like this

93:		$query2 = $db->simple_select("users", "uid,{$usergroup_select}", $sql_where);
94:		while($user = $db->fetch_array($query2))
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.
Just noticed this bug myself. Was going to report it but it seems you beat me to it.

Your fix works great, sayravai. Thanks. Cool