3030use TeampassClasses \SessionManager \SessionManager ;
3131use Symfony \Component \HttpFoundation \Request as SymfonyRequest ;
3232use Symfony \Component \Process \Process ;
33+ use Symfony \Component \Process \PhpExecutableFinder ;
3334use TeampassClasses \Language \Language ;
3435use TeampassClasses \ConfigManager \ConfigManager ;
3536
7677// Check if there is a task to execute
7778if (DB ::count () > 0 ) {
7879 // Execute or continue the task
79- subtasksHandler ($ processToPerform ['increment_id ' ], $ processToPerform ['arguments ' ]);
80+ subtasksHandler ($ processToPerform ['increment_id ' ], $ processToPerform ['arguments ' ], $ phpBinaryPath );
8081}
8182
82- function subtasksHandler ($ taskId , $ taskArguments )
83+ /**
84+ * Function to handle the subtasks
85+ *
86+ * @param int $taskId Task identifier
87+ * @param string $taskArguments Task arguments
88+ * @param string $phpBinaryPath Path to the PHP binary
89+ *
90+ * @return void
91+ */
92+ function subtasksHandler ($ taskId , $ taskArguments , $ phpBinaryPath ): void
8393{
8494 // Check if subtasks are still running
8595 // This in order to prevent the script from running multiple times on same objects
@@ -107,7 +117,7 @@ function subtasksHandler($taskId, $taskArguments)
107117 // Exit
108118 return ;
109119 }
110-
120+
111121 foreach ($ subTasks as $ subTask ) {
112122 // Launch the process for this subtask
113123
@@ -170,7 +180,7 @@ function subtasksHandler($taskId, $taskArguments)
170180 }
171181
172182 // Launch the subtask with the current parameters
173- $ process = new Process ([' php ' , __DIR__ .'/background_tasks___userKeysCreation_subtaskHdl.php ' , $ subTask ['increment_id ' ], $ subTaskParams ['index ' ], $ subTaskParams ['nb ' ], $ subTaskParams ['step ' ], $ taskArguments , $ taskId ]);
183+ $ process = new Process ([$ phpBinaryPath , __DIR__ .'/background_tasks___userKeysCreation_subtaskHdl.php ' , $ subTask ['increment_id ' ], $ subTaskParams ['index ' ], $ subTaskParams ['nb ' ], $ subTaskParams ['step ' ], $ taskArguments , $ taskId ]);
174184 $ process ->start ();
175185 $ pid = $ process ->getPid ();
176186
@@ -182,7 +192,7 @@ function subtasksHandler($taskId, $taskArguments)
182192 sleep (10 ); // Wait 10 seconds before continuing
183193
184194 // Recursively call this function until all subtasks are finished
185- subtasksHandler ($ taskId , $ taskArguments );
195+ subtasksHandler ($ taskId , $ taskArguments, $ phpBinaryPath );
186196}
187197
188198function createAllSubTasks ($ action , $ totalElements , $ elementsPerIteration , $ taskId )
0 commit comments