Firstly, great work on the module!
Was doing some testing before deciding whether to adopt this module for my needs (which I think I will!) and discovered that if you have a user subscribe to a subscription then unsubscribe all works as expected in terms of aquiring a role then releasing it.
If the same user then re-subscribes to the same subscription everything seems to process OK and they again re-aquire the correct role (and the DB is updated appropriately), HOWEVER, to the user, they still appear to be unsubscribed.
The problem is that the lm_paypal_user_subscribed function only picks up the first subscription instance from the lm_paypal_subscribers table when checking for the users "subscribed status" and that will appear to be "unsubscribed" (because of first cancelled subscription).
I managed to confirm this with a fairly brutal change (simply re-ordering the query) as shown below from the end of the lm_paypal_user_subscribed function:
// kind 0 is a role subscription, kind 1 is a group
//$sql = "SELECT uid, subid, status FROM {lm_paypal_subscribers} WHERE uid = %d AND subid = %d AND (kind = 0 OR kind = 2)";
$sql = "SELECT uid, subid, status FROM {lm_paypal_subscribers} "
. "WHERE uid = %d AND subid = %d AND (kind = 0 OR kind = 2) "
. "ORDER BY usid DESC";
$subs = db_query($sql, $uid, $subid);
if (db_num_rows($subs) <= 0) {
return FALSE;
}
$ss = db_fetch_object($subs);
if (! $ss) {
watchdog(
LM_PAYPAL_SUBSCRIPTIONS,
t('Cannot find the subscriber (uid %uid, subid %subid)', array('%uid' => $uid, '%subid' => $subid)),
WATCHDOG_ERROR);
return FALSE;
}
return ($ss->status == 1);
}
Now, that's probably NOT the best way to solve the problem as you will know better the implications of this scenario. Whether the act of re-subscribing should over-write the existing previous cancelled subscription is a question better answered by yourself (and would probably seem unsatisfactory as you loose your audit trail).
Hope that helps.
P.S. The comment above the changed line seems incorrect also? Should it say "2 is a group"?
Comments
Comment #1
skelly commentedI note that this was recently fixed in V1.26 of the module. <spank>Forgot to check HEAD before posting.</spank>