add tests batch 20
This commit is contained in:
@@ -24,34 +24,31 @@ class ConfigUpdateService
|
||||
|
||||
public function runTask(string $task, bool $dry, bool $force, DateTimeZone $tz): array
|
||||
{
|
||||
if (! isset($this->tasks[$task])) {
|
||||
if (!isset($this->tasks[$task])) {
|
||||
return ['ok' => false, 'message' => 'Unknown task.'];
|
||||
}
|
||||
|
||||
$lockFile = storage_path('app/locks/config_update_'.$task.'.lock');
|
||||
if (! is_dir(dirname($lockFile))) {
|
||||
$lockFile = storage_path('app/locks/config_update_' . $task . '.lock');
|
||||
if (!is_dir(dirname($lockFile))) {
|
||||
@mkdir(dirname($lockFile), 0775, true);
|
||||
}
|
||||
|
||||
$fp = @fopen($lockFile, 'c+');
|
||||
if (! $fp) {
|
||||
if (!$fp) {
|
||||
return ['ok' => false, 'message' => 'Unable to open lock file.'];
|
||||
}
|
||||
|
||||
if (! $force && ! flock($fp, LOCK_EX | LOCK_NB)) {
|
||||
if (!$force && !flock($fp, LOCK_EX | LOCK_NB)) {
|
||||
fclose($fp);
|
||||
|
||||
return ['ok' => false, 'message' => 'Task is already running.'];
|
||||
}
|
||||
|
||||
try {
|
||||
$method = $this->tasks[$task];
|
||||
$ok = (bool) $this->{$method}($dry, $force, $tz);
|
||||
|
||||
return ['ok' => $ok, 'task' => $task];
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('ConfigUpdate task failed: '.$e->getMessage());
|
||||
|
||||
Log::error('ConfigUpdate task failed: ' . $e->getMessage());
|
||||
return ['ok' => false, 'message' => $e->getMessage()];
|
||||
} finally {
|
||||
try {
|
||||
@@ -77,12 +74,11 @@ class ConfigUpdateService
|
||||
{
|
||||
$now = new DateTimeImmutable('now', $tz);
|
||||
$isJune1 = $now->format('n-j') === '6-1';
|
||||
if (! $isJune1 && ! $force) {
|
||||
if (!$isJune1 && !$force) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$value = $now->format('Y').'-12-31';
|
||||
|
||||
$value = $now->format('Y') . '-12-31';
|
||||
return $dry ? true : Configuration::setConfigValueByKey('date_age_reference', $value);
|
||||
}
|
||||
|
||||
@@ -90,7 +86,7 @@ class ConfigUpdateService
|
||||
{
|
||||
$now = new DateTimeImmutable('now', $tz);
|
||||
$isFeb1 = $now->format('n-j') === '2-1';
|
||||
if (! $isFeb1 && ! $force) {
|
||||
if (!$isFeb1 && !$force) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -101,7 +97,7 @@ class ConfigUpdateService
|
||||
{
|
||||
$now = new DateTimeImmutable('now', $tz);
|
||||
$isJun1 = $now->format('n-j') === '6-1';
|
||||
if (! $isJun1 && ! $force) {
|
||||
if (!$isJun1 && !$force) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user