65 if (!static::checkLock())
67 return self::THREAD_UNAVAILABLE;
70 \CTimeZone::Disable();
71 $thread = GroupThreadTable::getList(
78 '=GROUP_STATE_ID' => $this->groupStateId,
82 '=STATUS' => GroupThreadTable::STATUS_NEW,
85 '=STATUS' => GroupThreadTable::STATUS_IN_PROGRESS,
95 if (!isset($thread[
"THREAD_ID"]))
97 return self::THREAD_UNAVAILABLE;
99 $this->threadId = (int)$thread[
"THREAD_ID"];
100 $this->offset = $this->threadId === 0 && (int)$thread[
"STEP"] === 0
101 ? 0 : $this->threadId * $this->perPage + (static::lastThreadId() + 1) * $this->perPage * $thread[
"STEP"];
103 $this->
updateStatus(GroupThreadTable::STATUS_IN_PROGRESS);
152 if (
$status === GroupThreadTable::STATUS_DONE && !$this->checkToFinalizeStatus())
154 $status = GroupThreadTable::STATUS_NEW;
159 \CTimeZone::Disable();
162 $tableName = GroupThreadTable::getTableName();
163 $expireAt = (new \DateTime())->modify(
"+10 minutes")->format(
'Y-m-d H:i:s');
164 $updateQuery =
'UPDATE ' . $tableName .
'
168 EXPIRE_AT = \
'' . $expireAt .
'\'
170 THREAD_ID =
' . $this->threadId . '
171 AND GROUP_STATE_ID =
' . $this->groupStateId;
172 Application::getConnection()->query($updateQuery);
174 } catch (\Exception $e)
180 \CTimeZone::Enable();