WordPress filling up tables with wpsc_anonymous when WP e-Commerce plugin is installed
We recently came across a problem where a client site of ours had over 10,000 odd user accounts that were in their wp_users table.
All these users were prefixed by an underscore, like _ajasj3h1
All of these accounts had associated data in the wp_usermeta table, and one significant piece of data was that each group of records had “wpsc_anonymous” as part of the records in the wp_usermeta table.
This particular site is running PHP 5.5.11, running the latest MYSQL, running 126.96.36.199 version of WP e-Commerce and otherwise have no problems. One additional factor was this site was upgraded from an older version of WP E-Commerce.
After much investigation, I found that these records are temporary records that the WP E-Commerce plugin uses to track users in the shopping cart. These records are created by ANYONE – or ANY BOT on the site.
This client site was adding records at the rate of about 6 new users per minute.
WP E-Commerce is supposed to have a predefined CRON job which fires hourly, and deletes all records older than 12 hours.
This job is titled
However this job was not working properly as the temporary records were not deleting.
Lastly the fix for this turns out that the wp-config.php file was missing the following line:
define(‘WPSC_CUSTOMER_DATA_EXPIRATION’, 4 * 3600 );
that is required as part of the 188.8.131.52 version update.
Add that line of code to your wp-config.php file around line 50, below the other “Define” entries and restart the webserver engine.
this hourly job should now execute properly.
BY THE WAY -> I set mine to 4*3600 (or clear out records older than 4 hours). You can set yours to whatever value you’d like.
One more thing – don’t forget to edit your HOSTS file on that server and make sure you have an entry for your domain name, in that hosts file. CRON jobs need to execute on the domain name the site is running on, and unless you have a hosts file entry, it might not work.