2

We're running Civicrm 4.7.11, Drupal 7.56 on Cpanel.

I'm running cron via a custom php script that calls the url as per the civicrm cookbook.

All the jobs seem to get called except "Update Membership Statuses and Send Renewal Reminders" which fails with:

PHP Fatal error:  Call to a member function delete() on null in /home/sitename/public_html/sites/all/modules/civicrm/CRM/Member/BAO/Membership.php on line 659

Same error happens when running from drush, and when trying to execute manually via admin page I get a WSOD 500 error, which i guess is the same problem.

The issue seems to have occurred when moving to a new cpanel server which is using easyapache PHP instead of Cloudlinux.

Any ideas? PHP error? Civicrm? Drupal?

I've been holding off updating Civicrm due to a Leaflet maps issue with drupal.

Thanks Joe

2

I solved the issue with the help of xurizaemon on the Mattermost chat channel.

The script was failing because it was trying to delete a membership that looked like it was already deleted.

Hints below:

so "call to member function delete() on null" means that CiviCRM expected there to be an object and called a method on it - but the object didn't exist

i'd guess that here(https://github.com/civicrm/civicrm-core/blob/master/CRM/Member/BAO/Membership.php#L631) Civi tried to fetch a membership

then here(https://github.com/civicrm/civicrm-core/blob/master/CRM/Member/BAO/Membership.php#L665) Civi tried to delete the membership

but it didn't look to see if the first thing failed - and so when it tries to call delete on null, it falls over.

IMO it makes sense to inspect the result of line 631 before it treats it as an object

ie if ($membership = $memberships[$membershipId]) { /* do all the stuff with $membership */ }

or (easier to read) if (!$membership = $memberships[$membershipId]) { /* bail out / throw exception */ }

So I downloaded a DB dump to a dev environment. Checked the error was still there.

Then ran the task from the scheduled tasks page. With a vardump in the membership.php script just after the lines noted above.

var_dump($membership);

and then

var_dump($membershipID);

The memberships in the dump were both linked to the same parent membership, so I deleted that parent membership and recreated it from scratch.

Membership scheduled task is now running as usual.

I think the db may have been corrupted a bit on a recent server move.

  • We fixed this through this process but it since came back after new memberships. Did this happen to you? Any ideas on fixing this? Thanks – Sohal Khatwani Jun 19 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.