Commit 2f019c6c authored by Erick Hitter's avatar Erick Hitter
Browse files

Limit how many processes try to create or update the DB table

parent 096785ab
......@@ -14,6 +14,7 @@ class Events_Store extends Singleton {
const DB_VERSION = 1;
const DB_VERSION_OPTION = 'a8c_cron_control_db_version';
const TABLE_CREATE_LOCK = 'a8c_cron_control_creating_table';
const STATUS_PENDING = 'pending';
const STATUS_RUNNING = 'running';
......@@ -66,6 +67,11 @@ class Events_Store extends Singleton {
return;
}
// Limit chance of race conditions when creating table
if ( false === wp_cache_add( self::TABLE_CREATE_LOCK, 1, null, 1 * \MINUTE_IN_SECONDS ) ) {
return;
}
// Use Core's method of creating/updating tables
if ( ! function_exists( 'dbDelta' ) ) {
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment