WordPress and Paid Memberships Pro use a system called WP Cron to schedule events like the scripts that PMPro uses to manage membership expirations and queue up “expiring soon” emails.


PMPro v1.8.7 introduced a bug that was scheduling extra cron events… actually 3 extra events with every page load.Β On active sites (like our own site here), this quickly led to thousands of cron jobs being added, which would fill up the database and slow the site down to the point of failure.

It’s an incredibly nasty bug, and we’re very sorry to have introduced it.

Below is more information on who the bug affects and a few ways to clean it up. If you feel that the bug is affecting your site, and would like further help fixing this, please reach out in our member forums (fastest reply) or our contact form and we’ll resolve this for your site.


Who is this bug affecting?

  • Sites that ran PMPro v1.8.7 or 1.8.7.1 for any length of time.
  • Sites that are completely crashing.
  • Sites running significantly slower than expected even after updating to PMPro v1.8.7.2.

PMPro 1.8.7.3 Contains a Cleanup Script

If your site is running and you are able to access the WordPress dashboard, upgrading to PMPro 1.8.7.3 will run a script to clean up the redundant cron jobs. In our tests, this script always cleaned up the extra crons without halting as long as WordPress was loading in the first place. But please let us know if you experience any issues after upgrading to 1.8.7.3.


You Can Also Run a Separate Cleanup Plugin

If you have access to your WordPress dashboard, but you’d rather not upgrade PMPro (although we think you should), you can run the plugin created by Thomas Sjolshagen specifically to clean up the extra PMPro Crons. Download the zip file here and then upload and activate the plugin. (Some people have reported that they have to activate the plugin twice.)

 


Fixing Via MySQL if You Cannot Access the WordPress Dashboard

If you cannot access your WordPress dashboard to upgrade PMPro or use the cleanup plugin, follow the instructions below to clean your cron jobs up. This is an advanced technique and should be done with care.Β If you use plugins that make large use of the WP Cron system (e.g. WooCommerce Subscriptions), you will definitely want to back up the database first or at least the “cron” row in the wp_options table. And you will want to take extra care before running the steps below.

  1. Back up your database and files through your host or a backup plugin [more info].
  2. Run the following SQL command to delete all scheduled cron jobs.
    DELETE FROM wp_options WHERE option_name = 'cron';

    Note that your DB prefix may be something other than wp_ so update the command with your proper options table name

  3. Alternatively, on one system we were fixing this on the DELETE command above didn’t work. The following update command did:
    UPDATE wp_options SET option_value = '' WHERE option_name = '';
  4. If your website is still slow or not loading at this point, you should restart the Apache/HTTPD/NGINX/etc and MySQL/MySQLD services through your control panel or SSH.
  5. Deactivate and reactivate Paid Memberships Pro and any other plugin that you might need to have crons rescheduled for.
  6. Install the WP Crontrol plugin and go to Tools -> Scheduled Events to see what crons are scheduled. If you see a ton of redundant events with the same name/hook, then you might need to adjust and/or the SQL query above.

Other Notes

If your site is running fine, you can try to view the crons using a plugin like WP Crontrol to see if you really have an issue. And you can try to deactivate and reactivate Paid Memberships Pro, which will try to clear out the PMPro-specific crons. However, if there are a very large number of these, the deactivation may take your site off line. At which point, you should follow the steps above to fix the issue.

We’re committed to helping people fix things as quickly and painlessly as possible. If you need further help, please reach out in our member forums (fastest reply) or our contact form and we’ll resolve this for your site.

 


Author’s gravatar

I’ve got a slightly less (hopefully) intimidating approach to cleaning up the extra cron jobs and without “killing” all other jobs for other plugins. I’ve tested it on a couple of my own sites (live) and this seems to work w/o bad consequences. The plugin can be downloaded from https://eighty20results.com/protected-content/pmpro-fix-cron.zip.

A couple of things to note:

You may need to activate it more than once. By design, this plugin will self-deactivate, so when you click the “activate” link, you’ll see the site work for a little while and then return to the plugin page, but the PMPro Fix Cron plugin is _still_ (apparently)_ deactivated.

Use WP Control (for instance) to verify that all PMPro related cron jobs (`pmpro_cron_*`) are now removed.

Then you’ll have to deactivate & reactivate the main PMPro plugin (and any add-ons) again.

Reply
Author’s gravatar

NOTE: If you have _ANY_ PMPro add-ons active; Start the process by deactivating them _before_ you attempt to deactivate PMPro itself.

Reply
Author’s gravatar

NOTE 2: If you’re using Hostgator, I guess they have blacklisted the deactivate_plugin() function which caused an issue with my cronjob fixer.

Version 1.1 of the Fix PMPro Cron plugin takes this into account and will not attempt to self deactivate in those situations. You will then need to manually deactivate the plugin (or else it will disable your PMPro cron jobs every time your site loads).

Reply
Author’s gravatar

Excellent approach. I succeeded with a less optimal plugin, but one thing I could suggest is instead of using
add_action(‘init’, ‘fix_pmpro_cronjobs’);
you could use
register_activation_hook(__FILE__, ‘fix_pmpro_cronjobs’);
This will ensure the cleanup only runs when the plugin gets activated.

I also removed each cronjob according to the hook, with a separate registration of the plugin for each, e.g.
function cleanup_activation() {
// wp_clear_scheduled_hook( ‘pmpro_cron_expire_memberships’ );
wp_clear_scheduled_hook( ‘pmpro_cron_expiration_warnings’ );
}
register_activation_hook(__FILE__, ‘cleanup_activation’);

That reduces the workload and less chance of timing out. Still took several minutes of CPU to run though!

Author’s gravatar

My site has been shut down by hostgator due to “CPU abuse”. I finally got access to work on it and the PMPro plugin will not deactivate. Can I get some help to get this fixed?

Reply
Author’s gravatar

Thank you for this. It took me about 3 hours of searching to figure out why the site had been crashing in the first place. After intense googling and thanks to P3 (Plugin Performance Profiler) I finally checked the PMPro Support Site for answers. Your plugin saved our site and reduced our downtime, but I beg the question – why did this happen in the first place, and even if it does happen which is understandable Please Notify your users ASAP! We love PMPro and rely on it heavily for our business. Thanks again for your help.

Reply
Author’s gravatar

> why did this happen in the first place

While testing an update script to fix DB entries for Stripe orders to work with the latest version, I added a line to run the activation code on every load. I forgot to remove this line before committing changes.

We have been trying to notify users ASAP via the blog here. I suppose we could have emailed, and actually I’m going to push a notification into the dashboard for users who might still be running 1.8.7 or 1.8.7.1.

Reply
Author’s gravatar

Wow. That really was an ugly bug… Thanks for ‘fessing up though πŸ™‚

Our site was running really slow and I was starting to get worried about hacks and all sorts. We had CPU usage going through the roof, running out of resources, etc etc.

Removed that line from the DB and everything is back in the green zone again.

The only reason I looked up the error though was because I installed Sucuri Scan and seeing all the cron jobs in there.

I suspect there will be others who will struggle to find the root of their issues… Couldn’t you put a fix in with the next update somehow?

Reply
Author’s gravatar

Glad you got your site fixed up. This was messy.

I thought about pushing out a fix through the plugin or including a fix in the next update. I think we’ll have something, but it’s actually a tough problem. If we just wp_unschedule_event(…) or something similar, it has a good chance to time out. When I ran that on our site here, running on a dedicated server with 16GB of RAM, it crashed Apache. :/ Don’t want to do that to folks. The script that Thomas put together which loads the option “manually” and then cleans it up avoids some overhead, but could still cause issues… and won’t work if your site is so borked that you can’t load the WP admin.

I also think there is a trac ticket in the WP core about this issue. WP should do something to detect and throttle scheduled events like this. And we’ll follow up there to maybe get a fix in WP core to avoid this kind of thing.

Anyway. I think next week, we will have some kind of fix in PMPro that can help on sites that are slowed down by this but not totally broken. There are probably a lot of folks running PMPro that could use the automated fix if we can develop one that won’t break other sites.

Reply
Author’s gravatar

Thanks Jason for announcing the bug.

In case it helps others – just got one of our sites back up and running using the fix provided by Thomas. Still checking things out but don’t see any negative impacts yet.

Reply
Author’s gravatar

This is unbelievable! But the error was made. Now, please do a much better job of fixing it. On my new site, I cannot deactivate PMP. The site just hangs. I looked at WPCrontrol and there are hundreds, if not thousands of events. No schedules, though apparently. Do I have to delete each event individually? That will take days!
And your sql command lacks information in the extreme. Might be fine for a pro like yourself, but us humble users NEED MORE INFO!. Which database? Which table? Spell it all out, step by step.
Or better yet, release a plugin or script that fixes your mistake. Or, I will give you admin access, and YOU fix it all.
I am scheduled to demo the site tonight at an AGM. Now what?????

Alan

Reply
Author’s gravatar

Have you tried installing and activating the plugin that Thomas shared?

Where do you host? Ask your host how to access “phpMyAdmin” or a MySQL control panel. You might be able to ask your host to backup and run the steps above for you.

Reply
Author’s gravatar

It would have been really nice to have been notified of this right away. I have spent HOURS AND HOURS of time fighting with Hostgator lately and struggling to get my site back online with no idea what was going on. I didn’t want to turn off this plugin as it’s key to our membership-based site. Hostgator’s evil was easy to blame and I’m stilll changing hosting providers, but I will probably be looking for another membership managing plugin if this is the way you notify us of bugs that affect us so dramatically.

Reply
Author’s gravatar

To help us get better, how would you have liked to be notified of the issue?

Reply
Author’s gravatar

Preferably via email notification of just this issue. It was pure happenstance that (a) I happen to be subscribed to your newsletter and (b) I happened to click on the article that led me here. If I hadn’t done either of those things I’d still be in the dark. What about all the people who are experiencing the same sort of catastrophic failures on their site but aren’t subscribed to your newsletter? I get that you don’t want to publicize it until you also have a fix for it, but I lost hours of time trying to figure out why my site was getting shut down. At least if I knew PMPro had a bug that was causing it I could have taken measures quickly to shut down PMPro and get back online.

Author’s gravatar

Hi,
I am having the serious problem with the host (ipage.com) and they immediately suspended my site without any prior notice.

Below is the message the guys at ipage.com copied and sent to me. It does not mean anything to me because I cannot understand it, I know nothing about myphp or database management though I am able to set up databases for my hosting needs. However, the site has never been online but yet the plugin is running queries without someone using it.

“I apologize for the inconvenience this has caused to you. I was able to locate the plugin in your website which is causing this issue. The plugin name is β€˜paid-memberships-pro’. Please administrate your database and address the large queries. You may need to remove the above plugin from your website. You can find an excerpt from one of these queries below:

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
[snipped]
————————————————————————————–

If this query is important to your website, it may be that the frequency of the query can be dropped so that it is not causing a load to the server platform. You can also contact the plugin provider or their support for any workarounds.

Once the plugin has been removed or any action has been taken, please reply to this ticket and we will review the account.

Reply
Author’s gravatar

Are you able to update PMPro to the latest version? If you can’t access the WP dashboard to do that, can you contact us in the support forums or via the contact form so we can help?

Reply
Author’s gravatar

Jason, many thanks for the kind initiative. You guys are honestly “Interesfantic”. Updated to the newest version without any problem. Thank you for the work you are doing for the community.

Author’s gravatar

This was an ugly one for sure. But as others have said thanks a ton for letting us know it was an issue with this update. That way we don’t have to worry it will continue. Thanks for the great plugin!

Reply
Author’s gravatar

Have to say I respect all your hard work BUT I have been unable to fix this since it started
Did ALL the things suggested. Repeatedly. Clean up plugin WP Crontrol Advanved Cron, Updated
Completely Removed Your Product after running ALL the supposed fixes
Checked and rechecked still getting messages
Executable: /usr/bin/php

Command Line: /usr/bin/php /home/public_html/wp-cron.php

PID: 23461 (Parent PID:20912)

Killed: No

So in my world your “Oversight” has
Cost me hours of work
Pretty much broken a very important product launch site
Made it so I will never use your product or trust you ever again
My suggestion is be a lot more careful in the future

Reply
Author’s gravatar

I’m sorry again for the trouble this caused. It sounds like you’ve moved on, but if you’d like our help cleaning up, please reach out via our contact form, and I’ll see if there is something we can do.

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *