- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/countersprocessorinstaller.php
- Класс: CTaskCountersProcessorInstaller
- Вызов: CTaskCountersProcessorInstaller::setup
static function setup($step = self::STEP_BEGIN,
/** @noinspection PhpUnusedParameterInspection */ $extraParam = null)
{
$nextStep = $nextStepDelay = $nextStepExtraParam = null;
$timeLimit = microtime(true) + 5; // give at least 5 seconds for work
while (microtime(true) <= $timeLimit)
{
/** @noinspection PhpUnusedLocalVariableInspection */
$nextStep = $nextStepDelay = $nextStepExtraParam = null;
if ($step === self::STEP_BEGIN)
{
self::setStage(self::STAGE_INSTALL_IN_PROGRESS);
$nextStep = self::STEP_DROP_COUNTERS;
$nextStepDelay = 130;
}
else switch($step)
{
case self::STEP_DROP_COUNTERS:
// reset DEADLINE_COUNTED flags and all tasks counters for all users
self::reset();
$nextStep = self::STEP_COUNT_NEW_FOR_RESPONSIBLES;
break;
case self::STEP_COUNT_NEW_FOR_RESPONSIBLES:
self::recountCounters_MY_NEW($userId = '*'); // recount for all users
$nextStep = self::STEP_COUNT_NEW_FOR_ACCOMPLICES;
break;
case self::STEP_COUNT_NEW_FOR_ACCOMPLICES:
self::recountCounters_ACCOMPLICE_NEW($userId = '*'); // recount for all users
//$nextStep = self::STEP_COUNT_NEW_FOR_AUDITORS;
$nextStep = self::STEP_COUNT_WAIT_CTRL_FOR_ORIGINATORS;
break;
case self::STEP_COUNT_WAIT_CTRL_FOR_ORIGINATORS:
self::recountCounters_ORIGINATORS_WAIT_CTRL($userId = '*'); // recount for all users
$nextStep = self::STEP_COUNT_WITHOUT_DEADLINES_MY;
break;
case self::STEP_COUNT_WITHOUT_DEADLINES_MY:
self::recountCounters_MY_WITHOUT_DEADLINES($userId = '*'); // recount for all users
$nextStep = self::STEP_COUNT_WITHOUT_DEADLINES_FOR_ORIGINATORS;
break;
case self::STEP_COUNT_WITHOUT_DEADLINES_FOR_ORIGINATORS:
self::recountCounters_ORIGINATORS_WITHOUT_DEADLINES($userId = '*'); // recount for all users
$nextStep = self::STEP_COUNT_EXPIRED;
break;
case self::STEP_COUNT_EXPIRED:
$executionTimeLimit = mt_rand(1, 6); // time limit in seconds
$itemsProcessed = CTaskCountersProcessor::countExpiredAndExpiredSoonTasks($executionTimeLimit);
// Some items processed?
if ($itemsProcessed > 0)
{
// try again
$nextStep = self::STEP_COUNT_EXPIRED;
$nextStepDelay = 5;
}
else
{
self::setStage(self::STAGE_INSTALL_COMPLETE);
// CTaskCountersProcessorHomeostasis::onCalculationComplete();
$nextStep = null; // the end
}
break;
default:
CTaskAssert::logError('[0xd7b90d6d] ');
$nextStep = null; // the end
break;
}
if ($nextStep === null)
break;
if ($nextStepDelay > 0)
break;
$step = $nextStep;
}
if ($nextStep !== null)
{
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
return 'CTaskCountersProcessorInstaller::setup("' . $nextStep . '");';
}
return "";
}