Total Complexity | 102 |
Total Lines | 632 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
Complex classes like TCronModule often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use TCronModule, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
70 | class TCronModule extends \Prado\TModule implements IPermissions |
||
71 | { |
||
72 | /** The behavior name for the Shell Log behavior */ |
||
73 | public const SHELL_LOG_BEHAVIOR = 'shellLog'; |
||
74 | |||
75 | public const TASK_KEY = 'task'; |
||
76 | |||
77 | public const SCHEDULE_KEY = 'schedule'; |
||
78 | |||
79 | public const NAME_KEY = 'name'; |
||
80 | |||
81 | public const USERNAME_KEY = 'username'; |
||
82 | |||
83 | /** Key to global state of the last time SystemCron was run */ |
||
84 | public const LAST_CRON_TIME = 'prado:cron:lastcron'; |
||
85 | |||
86 | /** Key to global state of each task, lastExecTime and ProcessCount */ |
||
87 | public const TASKS_INFO = 'prado:cron:tasksinfo'; |
||
88 | |||
89 | /** The name of the cron user */ |
||
90 | public const DEFAULT_CRON_USER = 'cron'; |
||
91 | |||
92 | /** The separator for TCronMethodTask */ |
||
93 | public const METHOD_SEPARATOR = '->'; |
||
94 | |||
95 | /** The permission for the cron shell */ |
||
96 | public const PERM_CRON_SHELL = 'cron_shell'; |
||
97 | |||
98 | /** @var bool if the module has been initialized */ |
||
99 | protected $_initialized = false; |
||
100 | |||
101 | /** @var IUserManager user manager instance */ |
||
102 | private $_userManager; |
||
103 | |||
104 | /** @var TCronTaskInfo[] The info for tasks in the system. */ |
||
105 | private $_tasksInfo; |
||
106 | |||
107 | /** @var bool whether or not the $_tasks is properties or TCronTask */ |
||
108 | private $_tasksInstanced = false; |
||
109 | |||
110 | /** @var array[]|TCronTask[] the tasks */ |
||
111 | private $_tasks = []; |
||
112 | |||
113 | /** @var string The user Id of the tasks without users */ |
||
114 | private $_defaultUserName = self::DEFAULT_CRON_USER; |
||
115 | |||
116 | /** @var bool enable cron on requests, default false */ |
||
117 | private $_enableRequestCron = false; |
||
118 | |||
119 | /** @var numeric probability that a request cron will trigger [0.0 to 100.0], default 1.0 (for 1%) */ |
||
|
|||
120 | private $_requestCronProbability = 1.0; |
||
121 | |||
122 | /** @var null|bool is the app running in cron shell mode or not, or null for auto-detect */ |
||
123 | private $_inCronShell; |
||
124 | |||
125 | /** @var string the cli class to instance for CLI command line actions; this changes for TDbCronModule */ |
||
126 | protected $_shellClass = \Prado\Util\Cron\TShellCronAction::class; |
||
127 | |||
128 | /** @var array[] any additional tasks to install from properties */ |
||
129 | private $_additionalCronTasks; |
||
130 | |||
131 | /** |
||
132 | * Initializes the module. Read the configuration, installs Shell Actions, |
||
133 | * should Request cron be activated. |
||
134 | * @param array|\Prado\Xml\TXmlElement $config |
||
135 | * @throws TConfigurationException when the user manage doesn't exist or is invalid |
||
136 | */ |
||
137 | public function init($config) |
||
138 | { |
||
139 | $app = $this->getApplication(); |
||
140 | |||
141 | //Get the IUserManager module from the string |
||
142 | if (is_string($this->_userManager)) { |
||
143 | if (($users = $app->getModule($this->_userManager)) === null) { |
||
144 | throw new TConfigurationException('cron_usermanager_nonexistent', $this->_userManager); |
||
145 | } |
||
146 | if (!($users instanceof IUserManager)) { |
||
147 | throw new TConfigurationException('cron_usermanager_invalid', $this->_userManager); |
||
148 | } |
||
149 | $this->_userManager = $users; |
||
150 | } |
||
151 | |||
152 | // Otherwise manually look for the IUserManager |
||
153 | if ($this->_userManager === null) { |
||
154 | $users = $app->getModulesByType(\Prado\Security\IUserManager::class); |
||
155 | foreach ($users as $id => $module) { |
||
156 | $this->_userManager = $app->getModule($id); |
||
157 | break; |
||
158 | } |
||
159 | } |
||
160 | $this->_tasksInstanced = false; |
||
161 | |||
162 | //read config tasks and schedule |
||
163 | $this->readConfiguration($config); |
||
164 | |||
165 | //Read additional Config from Property |
||
166 | $this->readConfiguration($this->_additionalCronTasks); |
||
167 | $app->attachEventHandler('onAuthenticationComplete', [$this, 'registerShellAction']); |
||
168 | |||
169 | if ($app instanceof \Prado\Shell\TShellApplication) { |
||
170 | $app->registerOption('cron', [$this, 'setInCronShell'], 'If run in crontab, set this flag. It limits tasks to the current minute, default auto-detect'); |
||
171 | $app->registerOptionAlias('c', 'cron'); |
||
172 | } |
||
173 | |||
174 | if (php_sapi_name() !== 'cli' && $this->getEnableRequestCron()) { |
||
175 | if (100.0 * ((float) (mt_rand()) / (float) (mt_getrandmax())) <= $this->getRequestCronProbability()) { |
||
176 | $app->attachEventHandler('OnEndRequest', [$this, 'processPendingTasks'], 20); |
||
177 | } |
||
178 | } |
||
179 | $this->_initialized = true; |
||
180 | parent::init($config); |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * @param \Prado\Security\Permissions\TPermissionsManager $manager |
||
185 | * @return \Prado\Security\Permissions\TPermissionEvent[] |
||
186 | */ |
||
187 | public function getPermissions($manager) |
||
188 | { |
||
189 | return [ |
||
190 | new TPermissionEvent(static::PERM_CRON_SHELL, 'Activates cron shell commands.', 'dyRegisterShellAction'), |
||
191 | ]; |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * This reads the configuration and stores the specified tasks, for lazy loading, until needed. |
||
196 | * @param array|\Prado\Xml\TXmlElement $config the settings for cron |
||
197 | * @throws TConfigurationException when a PHP configuration is not an array or two jobs have the same name. |
||
198 | */ |
||
199 | protected function readConfiguration($config) |
||
200 | { |
||
201 | $isXml = false; |
||
202 | if (!$config) { |
||
203 | return; |
||
204 | } |
||
205 | if ($config instanceof \Prado\Xml\TXmlElement) { |
||
206 | $isXml = true; |
||
207 | $config = $config->getElementsByTagName('job'); |
||
208 | } elseif (is_array($config) && isset($config['jobs'])) { |
||
209 | $config = $config['jobs']; |
||
210 | } |
||
211 | foreach ($config as $properties) { |
||
212 | if ($isXml) { |
||
213 | $properties = array_change_key_case($properties->getAttributes()->toArray()); |
||
214 | } else { |
||
215 | if (!is_array($properties)) { |
||
216 | throw new TConfigurationException('cron_task_as_array_required'); |
||
217 | } |
||
218 | } |
||
219 | if (!($properties[self::NAME_KEY] ?? null)) { |
||
220 | $class = $properties[self::TASK_KEY] ?? ''; |
||
221 | $schedule = $properties[self::SCHEDULE_KEY] ?? ''; |
||
222 | $name = $properties[self::NAME_KEY] = substr(md5($schedule . $class), 0, 7); |
||
223 | } else { |
||
224 | $name = $properties[self::NAME_KEY]; |
||
225 | } |
||
226 | if (isset($this->_tasks[$name])) { |
||
227 | throw new TConfigurationException('cron_duplicate_task_name', $name); |
||
228 | } |
||
229 | $this->validateTask($properties); |
||
230 | $this->_tasks[$name] = $properties; |
||
231 | } |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * Validates that schedule and task are present. |
||
236 | * Subclasses overload this method to add their own validation. |
||
237 | * @param array $properties the task as an array of properties |
||
238 | * @throws TConfigurationException when the schedule or task doesn't exist |
||
239 | */ |
||
240 | public function validateTask($properties) |
||
241 | { |
||
242 | $schedule = $properties[self::SCHEDULE_KEY] ?? null; |
||
243 | $task = $properties[self::TASK_KEY] ?? null; |
||
244 | if (!$schedule) { |
||
245 | throw new TConfigurationException('cron_schedule_required'); |
||
246 | } |
||
247 | if (!$task) { |
||
248 | throw new TConfigurationException('cron_task_required'); |
||
249 | } |
||
250 | } |
||
251 | |||
252 | /** |
||
253 | * @param object $sender sender of this event handler |
||
254 | * @param null|mixed $param parameter for the event |
||
255 | */ |
||
256 | public function registerShellAction($sender, $param) |
||
257 | { |
||
258 | if ($this->dyRegisterShellAction(false) !== true && ($app = $this->getApplication()) instanceof \Prado\Shell\TShellApplication) { |
||
259 | $app->addShellActionClass(['class' => $this->_shellClass, 'CronModule' => $this]); |
||
260 | } |
||
261 | } |
||
262 | |||
263 | /** |
||
264 | * makes the tasks from the configuration array into task objects. |
||
265 | * @return \Prado\Util\Cron\TCronTask[] |
||
266 | */ |
||
267 | protected function ensureTasks() |
||
268 | { |
||
269 | if (!$this->_tasksInstanced) { |
||
270 | foreach ($this->_tasks as $properties) { |
||
271 | $name = $properties[self::NAME_KEY]; |
||
272 | $task = $properties[self::TASK_KEY]; |
||
273 | unset($properties[self::NAME_KEY]); |
||
274 | unset($properties[self::TASK_KEY]); |
||
275 | |||
276 | $task = $this->instanceTask($task); |
||
277 | |||
278 | $task->setName($name); |
||
279 | foreach ($properties as $key => $value) { |
||
280 | $task->$key = $value; |
||
281 | } |
||
282 | $this->setPersistentData($name, $task); |
||
283 | $this->_tasks[$name] = $task; |
||
284 | } |
||
285 | $this->_tasksInstanced = true; |
||
286 | } |
||
287 | return $this->_tasks; |
||
288 | } |
||
289 | |||
290 | /** |
||
291 | * This lazy loads the tasks from configuration array to instance. |
||
292 | * This calls {@see ensureTasks} to get the tasks and their persistent data. |
||
293 | * @return \Prado\Util\Cron\TCronTask[] currently active cron tasks |
||
294 | */ |
||
295 | public function getTasks() |
||
296 | { |
||
297 | $this->ensureTasks(); |
||
298 | return $this->_tasks; |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * These are the tasks specified in the configuration and getAdditionalCronTasks |
||
303 | * until {@see ensureTasks} is called. |
||
304 | * @return array[]|TCronTask[] currently active cron tasks |
||
305 | */ |
||
306 | public function getRawTasks() |
||
307 | { |
||
308 | return $this->_tasks; |
||
309 | } |
||
310 | |||
311 | /** |
||
312 | * This lazy loads the tasks. |
||
313 | * @param string $name |
||
314 | * @return TCronTask cron tasks with a specific name |
||
315 | */ |
||
316 | public function getTask($name) |
||
317 | { |
||
318 | $tasks = $this->getTasks(); |
||
319 | return $tasks[$name] ?? null; |
||
320 | } |
||
321 | |||
322 | /** |
||
323 | * . |
||
324 | * @param string $taskExec the class name or "module->method('param1')" to place |
||
325 | * into a {@see \Prado\Util\Cron\TCronMethodTask}. |
||
326 | * @return TCronTask the instance of $taskExec |
||
327 | */ |
||
328 | public function instanceTask($taskExec) |
||
329 | { |
||
330 | if (($pos = strpos($taskExec, self::METHOD_SEPARATOR)) !== false) { |
||
331 | $module = substr($taskExec, 0, $pos); |
||
332 | $method = substr($taskExec, $pos + 2); //String Length of self::METHOD_SEPARATOR |
||
333 | $task = new TCronMethodTask($module, $method); |
||
334 | } else { |
||
335 | $task = Prado::createComponent($taskExec); |
||
336 | if (!$task instanceof \Prado\Util\Cron\TCronTask) { |
||
337 | throw new TInvalidDataTypeException("cron_not_a_crontask", $taskExec); |
||
338 | } |
||
339 | } |
||
340 | return $task; |
||
341 | } |
||
342 | |||
343 | /** |
||
344 | * when instancing and then loading the tasks, this sets the persisting data of |
||
345 | * the task from the global state. When there is no instance in the global state, |
||
346 | * the lastExecTime is initialized. |
||
347 | * @param string $name name of the task. |
||
348 | * @param TCronTask $task the task object. |
||
349 | * @return bool updated the taskInfo with persistent data. |
||
350 | */ |
||
351 | protected function setPersistentData($name, $task) |
||
352 | { |
||
353 | $tasksInfo = $this->getApplication()->getGlobalState(self::TASKS_INFO, []); |
||
354 | if (isset($tasksInfo[$name])) { |
||
355 | $task->setLastExecTime($tasksInfo[$name]['lastExecTime']); |
||
356 | $task->setProcessCount($tasksInfo[$name]['processCount']); |
||
357 | return true; |
||
358 | } else { |
||
359 | $task->resetTaskLastExecTime(); |
||
360 | $task->setProcessCount(0); |
||
361 | $tasksInfo[$name]['lastExecTime'] = $task->getLastExecTime(); |
||
362 | $tasksInfo[$name]['processCount'] = 0; |
||
363 | $this->getApplication()->setGlobalState(self::TASKS_INFO, $tasksInfo, []); |
||
364 | } |
||
365 | return false; |
||
366 | } |
||
367 | |||
368 | /** |
||
369 | * @return TCronTask[] the tasks that are pending. |
||
370 | */ |
||
371 | public function getPendingTasks() |
||
372 | { |
||
373 | $pendingtasks = []; |
||
374 | foreach ($this->getTasks() as $name => $task) { |
||
375 | if ($task->getIsPending()) { |
||
376 | $pendingtasks[$name] = $task; |
||
377 | } |
||
378 | } |
||
379 | return $pendingtasks; |
||
380 | } |
||
381 | |||
382 | /** |
||
383 | * Filters the Tasks for a specific class. |
||
384 | * @param string $type |
||
385 | * @return TCronTask[] the tasks of $type |
||
386 | */ |
||
387 | public function getTasksByType($type) |
||
388 | { |
||
389 | $matches = []; |
||
390 | foreach ($this->getTasks() as $name => $task) { |
||
391 | if ($task->isa($type)) { |
||
392 | $matches[$name] = $task; |
||
393 | } |
||
394 | } |
||
395 | return $matches; |
||
396 | } |
||
397 | |||
398 | /** |
||
399 | * processPendingTasks executes pending tasks |
||
400 | * @return int number of tasks run that were pending |
||
401 | */ |
||
402 | public function processPendingTasks() |
||
403 | { |
||
404 | $inCronTab = (($inCron = $this->getInCronShell()) !== null) ? $inCron : TShellApplication::detectCronTabShell(); |
||
405 | $this->filterStaleTasks(); |
||
406 | $pendingTasks = $this->getPendingTasks(); |
||
407 | $numtasks = count($pendingTasks); |
||
408 | $startMinute = floor(time() / 60); |
||
409 | |||
410 | $this->logCron($numtasks); |
||
411 | if ($numtasks) { |
||
412 | foreach ($pendingTasks as $key => $task) { |
||
413 | if ($inCronTab && $startMinute != floor(time() / 60)) { |
||
414 | break; |
||
415 | } |
||
416 | $this->runTask($task); |
||
417 | } |
||
418 | } |
||
419 | |||
420 | return $numtasks; |
||
421 | } |
||
422 | |||
423 | /** |
||
424 | * @param int $numtasks number of tasks being processed |
||
425 | */ |
||
426 | protected function logCron($numtasks) |
||
427 | { |
||
428 | Prado::log("Processing {$numtasks} Cron Tasks", TLogger::INFO, TCronModule::class); |
||
429 | $this->dyLogCron($numtasks); |
||
430 | $this->setLastCronTime(microtime(true)); |
||
431 | } |
||
432 | |||
433 | /** |
||
434 | * This removes any stale tasks in the global state. |
||
435 | */ |
||
436 | protected function filterStaleTasks() |
||
437 | { |
||
438 | // Filter out any stale tasks in the global state that aren't in config |
||
439 | $app = $this->getApplication(); |
||
440 | $tasksInfo = $app->getGlobalState(self::TASKS_INFO, []); |
||
441 | $count = count($tasksInfo); |
||
442 | $tasksInfo = array_intersect_key($tasksInfo, $this->_tasks); |
||
443 | if ($count != count($tasksInfo)) { |
||
444 | $app->setGlobalState(self::TASKS_INFO, $tasksInfo, []); |
||
445 | } |
||
446 | } |
||
447 | |||
448 | /** |
||
449 | * Runs a specific task. Sets the user to the Task user or the cron module |
||
450 | * {@see getDefaultUserName}. |
||
451 | * @param \Prado\Util\Cron\TCronTask $task the task to run. |
||
452 | */ |
||
453 | public function runTask($task) |
||
454 | { |
||
455 | $app = $this->getApplication(); |
||
456 | $users = $this->getUserManager(); |
||
457 | $defaultUsername = $username = $this->getDefaultUserName(); |
||
458 | $restore_user = $app->getUser(); |
||
459 | $user = null; |
||
460 | |||
461 | if ($users) { |
||
462 | if ($nusername = $task->getUserName()) { |
||
463 | $username = $nusername; |
||
464 | } |
||
465 | $user = $users->getUser($username); |
||
466 | if (!$user && $username !== $defaultUsername) { |
||
467 | $user = $users->getUser($username = $defaultUsername); |
||
468 | } |
||
469 | |||
470 | if ($user) { |
||
471 | $app->setUser($user); |
||
472 | } elseif ($restore_user) { |
||
473 | $user = clone $restore_user; |
||
474 | $user->setIsGuest(true); |
||
475 | $app->setUser($user); |
||
476 | } |
||
477 | } |
||
478 | |||
479 | $this->logCronTask($task, $username); |
||
480 | $this->updateTaskInfo($task); |
||
481 | $task->execute($this); |
||
482 | $this->logCronTaskEnd($task); |
||
483 | |||
484 | if ($user) { |
||
485 | if ($restore_user) { |
||
486 | $app->setUser($restore_user); |
||
487 | } else { |
||
488 | $user->setIsGuest(true); |
||
489 | } |
||
490 | } |
||
491 | } |
||
492 | |||
493 | /** |
||
494 | * Logs the cron task being run with the system log and output on cli |
||
495 | * @param TCronTask $task |
||
496 | * @param string $username the user the task is running under. |
||
497 | */ |
||
498 | protected function logCronTask($task, $username) |
||
499 | { |
||
500 | Prado::log('Running cron task (' . $task->getName() . ', ' . $username . ')', TLogger::INFO, TCronModule::class); |
||
501 | $this->dyLogCronTask($task, $username); |
||
502 | } |
||
503 | |||
504 | /** |
||
505 | * sets the lastExecTime to now and increments the processCount. This saves |
||
506 | * the new data to the global state. |
||
507 | * @param TCronTask $task |
||
508 | */ |
||
509 | protected function updateTaskInfo($task) |
||
510 | { |
||
511 | $tasksInfo = $this->getApplication()->getGlobalState(self::TASKS_INFO, []); |
||
512 | $name = $task->getName(); |
||
513 | $time = $tasksInfo[$name]['lastExecTime'] = (int) microtime(true); |
||
514 | $count = $tasksInfo[$name]['processCount'] = $task->getProcessCount() + 1; |
||
515 | $task->setProcessCount($count); |
||
516 | $task->setLastExecTime($time); |
||
517 | |||
518 | $this->getApplication()->setGlobalState(self::TASKS_INFO, $tasksInfo, [], true); |
||
519 | } |
||
520 | |||
521 | /** |
||
522 | * Logs the end of the task. |
||
523 | * @param TCronTask $task |
||
524 | */ |
||
525 | protected function logCronTaskEnd($task) |
||
526 | { |
||
527 | Prado::log('Ending cron task (' . $task->getName() . ', ' . $task->getTask() . ')', TLogger::INFO, TCronModule::class); |
||
528 | $this->dyLogCronTaskEnd($task); |
||
529 | } |
||
530 | |||
531 | /** |
||
532 | * @return float time that cron last was last run |
||
533 | */ |
||
534 | public function getLastCronTime() |
||
535 | { |
||
536 | return $this->getApplication()->getGlobalState(self::LAST_CRON_TIME, 0); |
||
537 | } |
||
538 | |||
539 | /** |
||
540 | * @param float $time time that cron was last run |
||
541 | */ |
||
542 | public function setLastCronTime($time) |
||
543 | { |
||
544 | $this->getApplication()->setGlobalState(self::LAST_CRON_TIME, TPropertyValue::ensureFloat($time), 0, true); |
||
545 | } |
||
546 | |||
547 | /** |
||
548 | * Objects should handle fxGetCronTasks($sender, $param) |
||
549 | * @param bool $forceupdate if true, ignores the caching |
||
550 | * @return \Prado\Util\Cron\TCronTaskInfo[] |
||
551 | */ |
||
552 | public function getTaskInfos($forceupdate = false) |
||
553 | { |
||
554 | if (!$this->_tasksInfo || $forceupdate) { |
||
555 | $this->_tasksInfo = $this->raiseEvent('fxGetCronTaskInfos', $this, null); |
||
556 | } |
||
557 | return $this->_tasksInfo; |
||
558 | } |
||
559 | |||
560 | /** |
||
561 | * @return string the default user id of Tasks without users ids |
||
562 | */ |
||
563 | public function getDefaultUserName() |
||
564 | { |
||
565 | return $this->_defaultUserName; |
||
566 | } |
||
567 | |||
568 | /** |
||
569 | * @param string $id the default user id of Tasks without users ids |
||
570 | * @throws TInvalidOperationException if the module has been initialized |
||
571 | */ |
||
572 | public function setDefaultUserName($id) |
||
573 | { |
||
574 | if ($this->_initialized) { |
||
575 | throw new TInvalidOperationException('cron_property_unchangeable', 'DefaultUserName'); |
||
576 | } |
||
577 | $this->_defaultUserName = TPropertyValue::ensureString($id); |
||
578 | } |
||
579 | |||
580 | /** |
||
581 | * @return null|IUserManager user manager instance |
||
582 | */ |
||
583 | public function getUserManager() |
||
584 | { |
||
585 | return $this->_userManager; |
||
586 | } |
||
587 | |||
588 | /** |
||
589 | * @param null|IUserManager|string $provider the user manager module ID or the user manager object |
||
590 | * @throws TInvalidOperationException if the module has been initialized |
||
591 | * @throws TConfigurationException if the user manager is not a string, not an instance of IUserManager, and not null |
||
592 | */ |
||
593 | public function setUserManager($provider) |
||
602 | } |
||
603 | |||
604 | /** |
||
605 | * @return bool allow request cron task processing, default false |
||
606 | */ |
||
607 | public function getEnableRequestCron() |
||
610 | } |
||
611 | |||
612 | /** |
||
613 | * @param mixed $allow request cron task processing |
||
614 | * @throws TInvalidOperationException if the module has been initialized |
||
615 | */ |
||
616 | public function setEnableRequestCron($allow) |
||
617 | { |
||
618 | if ($this->_initialized) { |
||
619 | throw new TInvalidOperationException('cron_property_unchangeable', 'EnableRequestCron'); |
||
620 | } |
||
621 | $this->_enableRequestCron = TPropertyValue::ensureBoolean($allow); |
||
622 | } |
||
623 | |||
624 | /** |
||
625 | * @return numeric the probability 0.0 .. 100.0 of a request triggering a cron, default 1.0 (out of 100.0). |
||
626 | */ |
||
627 | public function getRequestCronProbability() |
||
628 | { |
||
629 | return $this->_requestCronProbability; |
||
630 | } |
||
631 | |||
632 | /** |
||
633 | * @param numeric $probability the probability 0.0..100.0 of a request triggering a cron |
||
634 | * @throws TInvalidOperationException if the module has been initialized |
||
635 | */ |
||
636 | public function setRequestCronProbability($probability) |
||
642 | } |
||
643 | |||
644 | /** |
||
645 | * @return null|bool is cli running from cron. |
||
646 | * @since 4.2.2 |
||
647 | */ |
||
648 | public function getInCronShell() |
||
649 | { |
||
650 | return $this->_inCronShell; |
||
651 | } |
||
652 | |||
653 | /** |
||
654 | * @param null|bool $inCronShell is cli running from cron. This limits |
||
655 | * pending tasks to only the current minute. |
||
656 | * @since 4.2.2 |
||
657 | */ |
||
658 | public function setInCronShell($inCronShell) |
||
661 | } |
||
662 | |||
663 | /** |
||
664 | * @return array additional tasks in a list. |
||
665 | */ |
||
666 | public function getAdditionalCronTasks() |
||
669 | } |
||
670 | |||
671 | /** |
||
672 | * This will take a string that is an array of tasks that has been |
||
673 | * through serialize(), or json_encode, or is an xml file of additional tasks. |
||
674 | * If one task is set, then it is automatically placed into an array. |
||
675 | * @param null|array|string $tasks additional tasks in an array [0..n], or |
||
676 | * a single task. |
||
677 | * @throws TInvalidOperationException if the module has been initialized |
||
678 | */ |
||
679 | public function setAdditionalCronTasks($tasks) |
||
702 | } |
||
703 | } |
||
704 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths