Current time: 07-05-2009, 03:10 AM Hello There, Guest! (LoginRegister)


 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] Only the first active promotion is processed
08-23-2008, 08:15 AM
Post: #1
[F] Only the first active promotion is processed
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:

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

Code:
93:        $query2 = $db->simple_select("users", "uid,{$usergroup_select}", $sql_where);
94:        while($user = $db->fetch_array($query2))
Visit this user's website Find all posts by this user
08-23-2008, 08:37 AM
Post: #2
[F] Only the first active promotion is processed
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.

[Image: ryangordon.png]
My Blog - My Mods - My Site
Visit this user's website Find all posts by this user
09-10-2008, 02:11 PM (This post was last modified: 09-10-2008 02:44 PM by Jed K.)
Post: #3
RE: [F] Only the first active promotion is processed
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

VQTE - Community for political talk & debate / 2008 election
FFXII US - Domain Café
Visit this user's website Find all posts by this user


Forum Jump: