Verified Commit 5337e4ab authored by Erick Hitter's avatar Erick Hitter
Browse files

Check the event-level lock first, ensuring Internal Events are locked at only the event level

Also avoids an event-level lock check failing, which would've wasted a space in the global lock for the current period.

Fixes #76
parent 8c41f475
...@@ -293,7 +293,12 @@ class Events extends Singleton { ...@@ -293,7 +293,12 @@ class Events extends Singleton {
* @return bool * @return bool
*/ */
private function can_run_event( $event ) { private function can_run_event( $event ) {
// Internal Events always run // Limit to one concurrent execution of a specific action
if ( ! Lock::check_lock( $this->get_lock_key_for_event_action( $event ), 1, JOB_LOCK_EXPIRY_IN_MINUTES * \MINUTE_IN_SECONDS ) ) {
return false;
}
// Internal Events aren't subject to the global lock
if ( is_internal_event( $event['action'] ) ) { if ( is_internal_event( $event['action'] ) ) {
return true; return true;
} }
...@@ -303,11 +308,6 @@ class Events extends Singleton { ...@@ -303,11 +308,6 @@ class Events extends Singleton {
return false; return false;
} }
// Limit to one concurrent execution of a specific action
if ( ! Lock::check_lock( $this->get_lock_key_for_event_action( $event ), 1, JOB_LOCK_EXPIRY_IN_MINUTES * \MINUTE_IN_SECONDS ) ) {
return false;
}
// Let's go! // Let's go!
return true; return true;
} }
......
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