Our user profiles have three tabs, the main "Account" tab, a "Personal Information" tab for our custom fields, and a "Taxonomy-based access" tab provided by the Taxonomy Access Control Lite module. If I make and save changes on either the "Personal Information" tab or the "Taxonomy-based access" tab, any role expiration dates are removed, although the role itself is still assigned.

Comments

a.bond’s picture

Is anyone going to fix this bug? It makes life very inconvenient.

stewsnooze’s picture

Assigned: Unassigned » stewsnooze

I am on holiday this week. I will fix this on monday.

Sorry for the delay

Stew

stewsnooze’s picture

I am on holiday this week. I will fix this on monday.

Sorry for the delay

Stew

stewsnooze’s picture

I am on holiday this week. I will fix this on monday.

Sorry for the delay

Stew

stewsnooze’s picture

I think I've found the bug.

In role_expire_user (hook_user)

case update and insert we always delete roles when the $role is not set. I need to check the form to make sure it was actually in there.

    foreach ($edit['role_expire'] as $rid => $role) {   
      if ($role) {
        $expiry_timestamp = strtotime($role);
        role_expire_write_record($account->uid, $rid, $expiry_timestamp);
      }
      else {
        // User input is blank, so delete record.
        role_expire_delete_record($account->uid, $rid);
      }
stewsnooze’s picture

Status: Active » Needs review

Mark Theunissen (http://drupal.org/user/108606) and I have fixed this in CVS HEAD, do you want to try that version so we can check back if you experience bad behaviour before I do a full release or do you require a full release today?

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/role_expire... will give you a link to get a new role_expire.module file for testing.

Let me know how you get on?

stewsnooze’s picture

Status: Needs review » Fixed

Fixed as part of 6.x-1.4.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

a.bond’s picture

Version: 6.x-1.3 » 6.x-1.6
Status: Closed (fixed) » Active

Today I upgraded to 6.x-1.6 and this bug has returned. Same as original, when I save changes to other tabs, role expirations vanish.

stewsnooze’s picture

Are you just downgrading until this is fixed?

a.bond’s picture

I'm downgrading, this bug makes the module far too difficult to work with.

stewsnooze’s picture

Status: Active » Needs review

Please test in 1.7. I really think I have it now. I fixed it in a more sustainable way this time. Big Big Apologies

stewsnooze’s picture

Status: Needs review » Fixed
a.bond’s picture

Just upgraded to 1.7 and it's working again. Thanks for the quick update.

bobgeier’s picture

Version: 6.x-1.6 » 6.x-1.7
Status: Fixed » Active

Hate to rain on the party, but I'm experiencing the same bug in 6.x-1.7, or perhaps a slightly different variant.

In my case, if a user who does not have permissions to administer roles (like the average user) updates their account information in any way, it erases the role expiration date. This renders the module functionally useless.

vacilando’s picture

Same problem in 6.x-1.7 -- the role expiration dates are disappearing (possibly as described in #15).

tuccio’s picture

Hello, I am also experiencing a similar issue. I have a system with the Registration Code module. Upon entering the code at registration, the user gets assigned a Valid_code role expiring in 365 days. Then on submitting the Contact form (it's a free consultation system) the user gets assigned, through Rules, a Monthly_filter role that expires in 30 days and prevents the user from submitting the form more often than once a month. Well, when the second role (Monthly_filter) gets assigned to the user, the expiration of the first role (Valid_code) gets erased. At first I thought it was a problem with Reg Code module (which has a role assignment functionality) so I modified the system not to use the Reg Code module role functionality, but the problem is still present now that I am only using Rules and Role Expire so I suspect the problem might be with Role Expire. Any help is greatly appreciated and thank you for the great module.

tuccio’s picture

I inserted some debug output and the problem seems still to occur inside the

else {
            // User input is blank, so delete record.
            role_expire_delete_record($account->uid, $rid);          
          }

block of the "insert" case of hook_user() which gets executed also when it should not.

However I am not very good at programming so at this time I cannot be of further help. But this problem needs to be fixed ASAP!

tuccio’s picture

More info: today I had a user who just requested a new password, and both his role expirations vanished.

bobgeier’s picture

Well, not being able to trace the bug, I can at least mention that if you comment out the line that tuccio lists in #18 it seems to make everything OK, except that you can no longer delete an expiration date on a role, only modify it or add it.

That might be enough for people to at least have adequate functionality until a real patch gets done.

stewsnooze’s picture

Hi,

The bug exists because the current design of the module allows any page that modifies the user object e.g hook_user to change the roles and it saves them.

The module basically should probably abandon the edit anywhere approach and simply support role expiration actions on the specified forms. e.g. /user/xxx/edit/xxx and the user admin create form. Are you saving data with this module in any way other than the default /user/xxx/edit/xxx pages?

stewsnooze’s picture

I've committed some code to CVS HEAD that doesn't remove the expiries when on other tabs. I'd love someone to test it on an instance they have had failures or have reproduced it on.

Any takers before I release this?

There should be a dev release for download on the role_expire project page within a day for testing.

Stew

stewsnooze’s picture

I should note here that for the next release people who are using hook_user to manipulate role_expire (role expiry) will need to make sure that category is set to 'account' or similar.

stewsnooze’s picture

Status: Active » Needs review
stewsnooze’s picture

Status: Needs review » Fixed

Released in 6.x.1.8

aitala’s picture

I just installed the update and I don't think it fixes the problem.

Tested on a site - account has a role with an expire date, user requests new password, logs in with one-time link, changes password. I check account with admin user and the role expire date is gone but user still has the role.

Eric

stewsnooze’s picture

Status: Fixed » Active

ok thanks for this. I'll try and reproduce again.

spacereactor’s picture

test with 6.x.1.8 and user expire role is gone after update/edit user profile.

stewsnooze’s picture

Status: Active » Needs review

This is a ridiculously embarrassing issue. An easy to fix bug that I have failed to do. Big Big Apologies. Comment #26 made me click that it was the actual user deleting their own role rather than the administrative user. Reading back beyond that I see that it is clear before then. I was so obsessed with thinking that the "administer users" role users were blanking it as the bug came back when I had committed admin users creating role expiry dates when they create users.

Big apologies. I believe this is fixed in 1.9.

Can one of you very patient folks please confirm that this is fixed for you?

spacereactor’s picture

so far it seem to work for me, but i only test when user update/edit own profile and the expire role remain. :) THANK!!

aitala’s picture

That appears to have worked as far as I can tell.

Eric

stewsnooze’s picture

Status: Needs review » Fixed
a.bond’s picture

Status: Fixed » Active

Using a bulk operation to add a role clears the expiration date of other roles.

stewsnooze’s picture

a "bulk operation" ? Are you using views bulk operations? can you explain the steps you took to get this bug in more detail please

stewsnooze’s picture

Status: Active » Postponed (maintainer needs more info)
a.bond’s picture

Yes, I'm using Views Bulk Operations. I have a Bulk Operations view created. When I use that view to apply a new role to users (views_bulk_operations_user_roles_action), it erases the expiration dates of any roles.

vacilando’s picture

As of version 1.9 expiration dates are present when re-editing. The initial problem seems to be solved...?

stewsnooze’s picture

Status: Postponed (maintainer needs more info) » Fixed

I agree. Lets close this issue and the VBO one can be separate

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

btown’s picture

Version: 6.x-1.7 » 6.x-1.x-dev

Hi Stew,

I'm using the current dev version and having the same problem with disappearing expiry dates. Originally I was using VBO, but given the discussion here, I changed so that users are flagging a node (using a simple link) in a table generated by views. Here's a quick overview of our set-up:

Users can publish and unpublish nodes that they have authored. They publish by flagging a node, which triggers a rule. The rule checks the user's roles and permits/declines to publish depending on the role of the user. It also updates the users' roles depending on how many nodes they have published.

Users have one role that is relatively fixed with an expiry date, and another role that is dynamic based on the number of nodes published. Whenever roles are updated by rules, the expiry date is cleared.

I'm also using the patch in #5 here: http://drupal.org/node/827594

btown’s picture

Status: Closed (fixed) » Active
stewsnooze’s picture

Hi @btown

Can you explain this a little more?

Are you saying that the role expiry date vanishes when a user is edited at /user/x/edit/sometab or that when you are using rules the date disappears. Right now the code is setup to only really react to the form being posted, which isn't the best, and when modules call user_save directly they don't always work. I'd love to get more information on this one as it won't die!

Anything you can give me to reproduce such as a feature would be appreciated.

Stew

btown’s picture

Status: Active » Closed (fixed)

Hey Stew,

I'm closing this issue as I've managed to figure out the problem. It was caused by the module "role expiry operations", which we don't really need. I deactivated that module and the problem is resolved.

For reference purposes, the expiry dates were being cleared when one of the admins tried to manually change something on a user account or when one of the admins triggered a rule. I started to figure out the problem when I realized that non-administrators were having no problems with role expiry dates.

I know nothing about the code, but thought it was interesting that Role Expiry Operations caused the problem even when we weren't actually using the module, it was just active in the background.

Let me know if you need any further clarification. Thanks for this great module!

Barry

btown’s picture

A further update:

Our site uses the LDAP integration module with mixed mode authentication (i.e. some accounts authenticate against LDAP whereas others are local accounts only). When we configured the LDAP Data to be read only, then expiry dates could not be manually entered, and attempts to manually change expiry dates wiped out any dates that had been automatically created by rules.

Even though our LDAP server won't accept updates from Drupal, the LDAP Integration module has to be configured to read/write. This might seem inconsistent with the instructions that come with LDAP Integration, but it seems to work.