Found this edge case bug when developing a custom feature for a client.

When cron is run I loads all users who are within a day of their expiry date and adds a field to the users $data array and then saves. This then removes the users entry from the role_expire table.

It runs through line 389 for each role and removes them all. Has anyone seen this before?

Comments

stewsnooze’s picture

I definitely have not seen this before. Were you running cron as an authenticated user or through wget/drush ? user_save does different things depending on who is logged in which I hate but it would be interesting to know?

mikebell_’s picture

I was running it through drush as anon. I'll test as an authed user and report back.

mikebell_’s picture

Ok even if I run it as uid 1 it's still being removed.

The role is initially applied using role_expire_write_record() on a node_save if that helps.

From looking through the code this is happening because $role is blank (see line 374). The array_key_exists() check is failing. I have no idea why this would be happening.

mikebell_’s picture

I keep going round in circles trying to find an issue with this but can't, the following patch does some minor code formatting changes and comments out the offending call to role_expire_delete_record(). It's most likely wrong and will break things for others but my testing finds no issues in this use case.

mikebell_’s picture

New patch with compat for http://drupal.org/node/1504216

stewsnooze’s picture

Status: Active » Needs work

This last patch doesn't seem right. It just comments out a call to a function which in essence makes the whole else clause not needed. If this is your intended functionality then the whole else clause should be taken out.

rcodina’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

Drupal 6 version is unsupported!