PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.02
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.02
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
fluent-booking / vendor / woocommerce / action-scheduler / classes / ActionScheduler_FatalErrorMonitor.php

ActionScheduler_FatalErrorMonitor.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 1.5.02, at vendor/woocommerce/action-scheduler/classes/ActionScheduler_FatalErrorMonitor.php

56 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class ActionScheduler_FatalErrorMonitor
5 */
6 class ActionScheduler_FatalErrorMonitor {
7 /** @var ActionScheduler_ActionClaim */
8 private $claim = NULL;
9 /** @var ActionScheduler_Store */
10 private $store = NULL;
11 private $action_id = 0;
12
13 public function __construct( ActionScheduler_Store $store ) {
14 $this->store = $store;
15 }
16
17 public function attach( ActionScheduler_ActionClaim $claim ) {
18 $this->claim = $claim;
19 add_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
20 add_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0, 1 );
21 add_action( 'action_scheduler_after_execute', array( $this, 'untrack_action' ), 0, 0 );
22 add_action( 'action_scheduler_execution_ignored', array( $this, 'untrack_action' ), 0, 0 );
23 add_action( 'action_scheduler_failed_execution', array( $this, 'untrack_action' ), 0, 0 );
24 }
25
26 public function detach() {
27 $this->claim = NULL;
28 $this->untrack_action();
29 remove_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
30 remove_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0 );
31 remove_action( 'action_scheduler_after_execute', array( $this, 'untrack_action' ), 0 );
32 remove_action( 'action_scheduler_execution_ignored', array( $this, 'untrack_action' ), 0 );
33 remove_action( 'action_scheduler_failed_execution', array( $this, 'untrack_action' ), 0 );
34 }
35
36 public function track_current_action( $action_id ) {
37 $this->action_id = $action_id;
38 }
39
40 public function untrack_action() {
41 $this->action_id = 0;
42 }
43
44 public function handle_unexpected_shutdown() {
45 if ( $error = error_get_last() ) {
46 if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) {
47 if ( !empty($this->action_id) ) {
48 $this->store->mark_failure( $this->action_id );
49 do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error );
50 }
51 }
52 $this->store->release_claim( $this->claim );
53 }
54 }
55 }
56