Hi, I am using User Referral along with Userpoints, and I have an interesting new issue: the referral link is occasionally, not always, displayed wrong - as all 7's, e.g. www.site.com/referral/777777xx (where xx is something in hex code). When this happens, it seems to be the case for a few minutes for all users, and then it sorts itself out and goes back to displaying the right codes again. The all-7 codes do not work, i.e. do not result in storing the cookie, or in any case points are not awarded as they usually are when the correct codes are used.
I don't know what makes them reset to the proper codes, possibly a cron run? I sometimes have to log out and in again a few times before it gets set right again.
I confess I have mucked about in the code somewhat, transferring the call to userpoints to the login_toboggan module so that it is called when the new user validates, rather than immediately; however these were minor changes and they are working, and in any case I don't see why it would interfere with the referral module displaying the proper code on the user page, or (even more mysteriously) why it would do this only intermittently. However, I did not notice this happening before I installed the login_toboggan module. Possibly a conflict in there somewhere?
any suggestions? anyone seen this?
thanks in advance...
Comments
Comment #1
subtlearts commentednobody with anything to say about this at all? Any ideas as to why referral would occasionally churn out a completely bogus referral code? please?
Comment #2
kbahey commentedThe calculation that generates a referral code uses the $base_url variable.
Maybe your site does not have $base_url configured in settings.php AND you don't have your web server redirecting example.com to www.example.com? In this case the calculation of the referral code will be wrong.
Try adding it to your settings.php and see if that works.
Comment #3
subtlearts commentedThanks, I have installed those fixes, and will test to see if the behaviour persists.
Comment #4
dzaretsky commentedThis is actually still a bug in Drupal 7. The problem is that the referral ID is based off of the base_url variable. In fact, it selects the substring from characters 7-11. For whatever reason, this was set up as such, but is a very sill way to do this. The reason this error appears is because when your browser URL address begins with http://www.yourdomain.com versus http://yourdomain.com, the substring characters will change. The value you are seeing is the hex representation of 'www.' which is 0x7777772e + your account UID. If you change the URL address in the browser to the latter, you should see the correct referral ID.
The fix would be to strip out the 'www.' from the base_url:
$base_url = str_replace('www.', '', $GLOBALS['base_url']);