Status
Not open for further replies.

Will.Spencer

Customer
We've installed vBCredits Deluxe II when upgrading from vB3 to vB4 as a replacement for the original vBCredits which we used before, but we begun noticing that some members are getting way too many credits.

At first we thought it might be something in the settings so we reconfigured everything, made sure our activity amounts are right, deactivated and then tried deleting the deactivated events, and doing the recalculation according to these instructions, but it didn't help.

We noticed that when we go to Recalculate User Account and exact match a user, then click user name to see all user transactions the transactions look right, and the statistics show what should be the actual number of credits, yet in the credits field the number is wildly off.

It is as if the recalculation isn't doing it properly, and is introducing some unknown variable that messes everything up.

I'm not sure how is this related, but simultaneously it is also happening that for one user at least (me) donations are being applied multiple times instead of only once. I made one donation recently and it is for some reason showing 5 times more every time I do a recalculation for my username, and this affects the credits number.

What could be going on? Ideally the recalculation should match the statistics on the user transactions log.

-- Posted by memenode from NetBuilders.org (I work for Will).
 
There were some recalculation bugs that happen if you run it more than once at a time which I fixed for someone else. I can do the same for you if you PM me ftp access and and admin login while I finalize it for the next release.
 
In (forum)/dbtech/credits/credits_core.php find

PHP:
    function shutdown()
    {
        global $vbulletin;
        $obj =& VBCREDITS::init();
        if (sizeof($obj->insert)) VBCREDITS::commit();
        if ($obj->douser) VBCREDITS::update($vbulletin->userinfo);
        $obj->douser = false;
    }

    function update(&$userinfo)
    {    //string together all the currencies to update unbuffered
        if ($userinfo['userid'])
        {
            global $vbulletin;
            $db =& $vbulletin->db;
            $query = array(array(), array(), array());

            foreach ($vbulletin->vbcredits['currency'] AS $currencyid => $currency)
            {
                $table = 'vbcreditst_' . $currencyid;
                $query[0][] = ( $currency['useprefix'] ? TABLE_PREFIX : '' ) . $currency['table'] . ' AS ' . $table;
                $query[1][] = $table . '.' . $currency['column'] . ' = ' . $table . '.' . $currency['column'] . ' + ' . ($userinfo['vbcredits_' . $currencyid] - $userinfo['vbcreditsb_' . $currencyid]);
                $query[2][] = $table . '.' . $currency['usercol'] . ' = ' . ( $currency['userid'] ? $userinfo['userid'] : "'" . $db->escape_string(htmlspecialchars_uni($userinfo['username'])) . "'" );
                $userinfo['vbcreditsb_' . $currencyid] = $userinfo['vbcredits_' . $currencyid];//reset backup
            }

            $db->query_write("UPDATE " . implode(', ', $query[0]) . " SET " . implode(', ', $query[1]) . " WHERE " . implode(' AND ', $query[2]), false);
        }
    }

replace with

PHP:
    function shutdown()
    {
        global $vbulletin;
        $obj =& VBCREDITS::init();
        if (sizeof($obj->insert)) VBCREDITS::commit();
        if ($obj->douser) VBCREDITS::update($vbulletin->userinfo, true);
        $obj->douser = false;
    }

    function update(&$userinfo, $relative = false)
    {    //string together all the currencies to update unbuffered
        if ($userinfo['userid'])
        {
            global $vbulletin;
            $db =& $vbulletin->db;
            $query = array(array(), array(), array());

            foreach ($vbulletin->vbcredits['currency'] AS $currencyid => $currency)
            {
                $table = 'vbcreditst_' . $currencyid;
                $current = $userinfo['vbcredits_' . $currencyid];
                $query[0][] = ( $currency['useprefix'] ? TABLE_PREFIX : '' ) . $currency['table'] . ' AS ' . $table;
                $query[1][] = $table . '.' . $currency['column'] . ' = ' . ( $relative ? $table . '.' . $currency['column'] . ' + ' . ($current - $userinfo['vbcreditsb_' . $currencyid]) : $current );
                $query[2][] = $table . '.' . $currency['usercol'] . ' = ' . ( $currency['userid'] ? $userinfo['userid'] : "'" . $db->escape_string(htmlspecialchars_uni($userinfo['username'])) . "'" );
                $userinfo['vbcreditsb_' . $currencyid] = $current;//reset backup
            }

            $db->query_write("UPDATE " . implode(', ', $query[0]) . " SET " . implode(', ', $query[1]) . " WHERE " . implode(' AND ', $query[2]), false);
        }
    }
 
That didn't work. After modifying the file we tested it by recalculating a couple of users. The transactions sum still doesn't match the amount of credits. A user who should have 142 credits (according to the transactions sum, which is what makes sense) has over 4000.

EDIT: I should note that I'm not getting a donation counted as multiple times though, so at least that seems right now, but I'm not sure if it's related to this fix.

-- memenode
 
Last edited:
Here's a screenshot of it:

recalc.png

We're just trying to get the credits of each user reflect what it should be from the beginning of the forum till today according to our rules for rewarding them, which were now set up in Activity Amounts Configuration.

We just ran a script that copied the transactions sum to the credits amount (via MySQL) so that they match. That's one way to do the recalculation instead of using the UI. What we noticed though is that the site's owner (Will) has a huge negative amount, yet I can't find any charges in his transactions log. There are also a number of users which were awarded 100 credits for joining a forum multiple times (which should be impossible).

Another user who just joined seems to have gotten rewarded for joining twice, but it shows this in the transaction log only once. It is only in MySQL that we can see it twice, and in his inflated number of credits. The difference between these two entries is in that one has a "status" of "1", and another a status "4". What is this status?

This is what it looks like:

Code:
+---------------+---------+-----------+--------+------------+--------+--------+-------------+---------+---------+------------+------------+--------+---------+
| transactionid | eventid | actionid  | userid | timestamp  | amount | status | referenceid | forumid | ownerid | multiplier | currencyid | negate | message |
+---------------+---------+-----------+--------+------------+--------+--------+-------------+---------+---------+------------+------------+--------+---------+
|        437861 |      15 | induction |  14066 | 1304065521 |    100 |      1 | NULL        |       0 |       0 |          0 |          1 |      0 |         |
|        437862 |      15 | induction |  14066 | 1304065720 |    100 |      4 | NULL        |       0 |       0 |          0 |          1 |      0 |         |

Can you sense what could be wrong with all this? It seems there is not only an issue with the recalculation system (which we bypassed by copying transaction sums to the credit amounts), but with the way transactions themselves and/or their summing happens.

-- memenode
 
Last edited:
The problem is, for large forum resets like you are trying to do, you should set reverse first to no, and target any time and action to both yes. then, set 0 for both the formulas, and if you have many pages of results, yes to that too. after it has gone through everyone, be sure to click the link to process pending transactions that it presents to you at the top of the page, and after it has finished that, check the amounts with what you think they should be.
 
We still have one remaining issue though. For transactions which were accounted for the recalculation looks good, but it didn't account for all past transactions, namely where people sent credits to each other using the old vBCredits system. From my understanding the closest equivalent to that in vBCredits II is the donation event, but in any case it didn't seem to pick up those old transfers. Is there a way to make sure all transactions from the old vBCredits system are accounted for? What are the new equivalents? Are we missing something?

Thank you

-- memenode.
 
Due to the completely rewritten modular structure of vbcredits II, only currencies and amounts users had are retained during the vBCredits 1.x line and vBCredits II. Old transactions and such are not converted, but may in the future (the tables are kept)
 
Status
Not open for further replies.

Similar threads

Legacy vBCredits II Deluxe

vBulletin 3.8.x vBulletin 4.x.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
845
Customer rating
0.00 star(s) 0 ratings
Top