I noticed my registrations created in the Held state weren't being cancelled after about an hour like they're supposed to. So I ran cron manually. When I did, I got these notices:

  • Notice: Trying to get property of non-object in registration_cron() (line 1160 of /var/www/asiancdc/trunk/docroot/sites/all/modules/registration/registration.module).
  • Notice: Undefined variable: result in registration_cron() (line 1160 of /var/www/asiancdc/trunk/docroot/sites/all/modules/registration/registration.module).
  • Notice: Trying to get property of non-object in registration_cron() (line 1160 of /var/www/asiancdc/trunk/docroot/sites/all/modules/registration/registration.module).
  • Notice: Trying to get property of non-object in registration_cron() (line 1162 of /var/www/asiancdc/trunk/docroot/sites/all/modules/registration/registration.module).
  • Notice: Trying to get property of non-object in registration_cron() (line 1160 of /var/www/asiancdc/trunk/docroot/sites/all/modules/registration/registration.module).
  • Notice: Undefined variable: result in registration_cron() (line 1160 of /var/www/asiancdc/trunk/docroot/sites/all/modules/registration/registration.module).
  • Notice: Trying to get property of non-object in registration_cron() (line 1160 of /var/www/asiancdc/trunk/docroot/sites/all/modules/registration/registration.module).
  • Notice: Trying to get property of non-object in registration_cron() (line 1162 of /var/www/asiancdc/trunk/docroot/sites/all/modules/registration/registration.module).

Held registrations are still not cancelled after running cron. Not sure what's going on. It'd be nice to get this working soon.

Comments

WhenBirdsOink created an issue. See original summary.

bartidris’s picture

There's a bug inside the registration.module file, in the registration_cron() function.

This works for me:

  // Determine whether hold expire minimum time time has elapsed.
  // Setting for how long the hold lasts is stored on the registration type entity.
  $registration_type = entity_load_single('registration_type', $registration_wrapper->type->value());      
  // Change registration state if hold has expired.
  // Expiration time is in hours - hence the multiplication.      
  if ((time() - ($registration_type->held_expire * 60 * 60)) > $registration_wrapper->created->value() ) {
    // Set registration state to what is configured for its registration type.
    $registration_wrapper->state->set($registration_type->held_expire_state);        
    $registration_wrapper->save();
   }

For my site, I'm expiring held registrations against their created date. If you want to check against their updated date you should use $registration_wrapper->updated->value() instead of $registration_wrapper->created->value() in the snippet above.

fonant’s picture

Needed two fixes for me:

1. Patch to save the expiration time and expired state into the registration_type's data field:
https://www.drupal.org/project/registration/issues/2818141

2. Change line from 1161 (in release 7.x-1.6):

      $registration_type = entity_load_single('registration_type', $registration_wrapper->entity_id->value());

to:

      $registration_type = registration_type_load($registration->type);
Chris Matthews’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Active » Closed (outdated)