I have been fighting a problem with user subscriptions on my site for some time. It would take some time for a user to obtain access to the subscriber viewable items on my site. I am using the Subscription Tools from Ventrian ( highly recommended by the way) and works as expected except for this one issue.
I originally blamed everyone else (a good trait of a developer) - first PayPal, then subscription module, then server performance, then caching ... Yesterday, I happened to be on the site and trying once more to figure this out when a user subscribed to the site. Perfect, I immediate validated all the appropriate tables to ensure all was correct. I contacted the user and asked to see if he did have access.
Time passed -- no response from the user, so ignorance is bliss, so I happily figured he had access. Not my problem.
Well then came the email ... no access. ugh! MY PROBLEM -- got to deal with this.
As I saw that Paypal interaction with the subscription tool had correctly populated all of the appropriate tools, Paypal was off the hook. So too was the Ventrian software as all was valid. So I was left with caching. Since my site is V4.9.4, I opened a copy of the source and figured there must be some sort of caching associated with the UserRoles. Well after several minutes I found there is NO CACHING of this information that I could find. Rats ... I'll deal with tomorrow. Another good trait of a developer -- procrastination!
OK, so what could it be?. All that was left was the server performance. My host is DotNetPark and they have provided solid hosting for me over the last 3 years. Performance varies as it does with all shared hosting accounts and to be honest, my site is not very busy relative to other sites, so occasionally my site is asleep and does take a while to "spin up". However, I was working on the site at the time of the user's subscription, so the performance was not an issue and more to the point, all the update were performed.
So when all else fails - back to basics. The missing access is a menu item allowing the users to access the downloads for the various modules. Access is controlled via the Users role assign when subscribed. So I checked the UserRoles table for the recent subscribed user and found exactly what I expected. The user had an record associating him to the role with a valid Effective and Expiry Date. hmmmm.
What time is it really? So I asked the SQL server with Print Getdate() command. To my surprise --- it was not the current date and time but 3 hours behind... I was expected 11am and got 9am. Have I found my missing few hours?
It now makes sense. Never really thought about this issue before. So it seems that my hosting company have defaulted the server to run in Pacfic time, hence the 3 hour difference. So when someone subscribed to my site, the effective time was 3 hours into the future. I will need to alter the UpdateUserRole to remove 3 hours to the Effective Date until an alternative permiment fix can be implemented.
Update: The issue is a bit more complicated that I originally thought. This issue also deals with the default and user time zones. So while this user was from the same time zone (Eastern) the problem was a difference of 3 hours -- if they have been from the Pacific Time zone (and had changed their profile) all would have worked. The issue is still the same -- user time vs. server time.
I created this query to help validate what time is it really!
Select 'Local Time' as [What], Convert(varchar, dateAdd(hh,-4, getUTCdate()), 113) as [Value]
Union
Select 'Sever Time' as [What], Convert(varchar, getdate(), 113) as [Value]
Union
Select 'UTC Time' as [What], Convert(varchar, getUTCdate(), 113) as [Value]
Notice that the Local time is expressed as UTC time minus the time zone offset.
So do you know what time it is?
Good Luck!
Paul