@@ -105,6 +105,14 @@ class Email_Reporting {
105105 */
106106 protected $ initiator_task ;
107107
108+ /**
109+ * Worker task instance.
110+ *
111+ * @since n.e.x.t
112+ * @var Worker_Task
113+ */
114+ protected $ worker_task ;
115+
108116 /**
109117 * Constructor.
110118 *
@@ -130,11 +138,14 @@ public function __construct(
130138
131139 $ frequency_planner = new Frequency_Planner ();
132140 $ subscribed_users_query = new Subscribed_Users_Query ( $ this ->user_settings , $ this ->modules );
141+ $ max_execution_limiter = new Max_Execution_Limiter ( (int ) ini_get ( 'max_execution_time ' ) );
142+ $ batch_query = new Email_Log_Batch_Query ();
133143
134144 $ this ->rest_controller = new REST_Email_Reporting_Controller ( $ this ->settings );
135145 $ this ->email_log = new Email_Log ( $ this ->context );
136146 $ this ->scheduler = new Email_Reporting_Scheduler ( $ frequency_planner );
137147 $ this ->initiator_task = new Initiator_Task ( $ this ->scheduler , $ subscribed_users_query );
148+ $ this ->worker_task = new Worker_Task ( $ max_execution_limiter , $ batch_query , $ this ->scheduler );
138149 }
139150
140151 /**
@@ -154,6 +165,7 @@ public function register() {
154165 $ this ->scheduler ->schedule_initiator_events ();
155166
156167 add_action ( Email_Reporting_Scheduler::ACTION_INITIATOR , array ( $ this ->initiator_task , 'handle_callback_action ' ), 10 , 1 );
168+ add_action ( Email_Reporting_Scheduler::ACTION_WORKER , array ( $ this ->worker_task , 'handle_callback_action ' ), 10 , 3 );
157169
158170 } else {
159171 $ this ->scheduler ->unschedule_all ();
0 commit comments