self::$process = $process;
// Kill stale processes every 5 minutes
- $last_cleanup = DI::config()->get('system', 'worker_last_cleaned', 0);
+ $last_cleanup = DI::keyValue()->get('worker_last_cleaned') ?? 0;
if (time() > ($last_cleanup + 300)) {
- DI::config()->set('system', 'worker_last_cleaned', time());
+ DI::keyValue()->set( 'worker_last_cleaned', time());
Worker\Cron::killStaleWorkers();
}
$stamp = (float)microtime(true);
$condition = ["`id` = ? AND `next_try` < ?", $queue['id'], DateTimeFormat::utcNow()];
if (DBA::update('workerqueue', ['done' => true], $condition)) {
- DI::config()->set('system', 'last_worker_execution', DateTimeFormat::utcNow());
+ DI::keyValue()->set('last_worker_execution', DateTimeFormat::utcNow());
}
self::$db_duration = (microtime(true) - $stamp);
self::$db_duration_write += (microtime(true) - $stamp);
$stamp = (float)microtime(true);
if (DBA::update('workerqueue', ['done' => true], ['id' => $queue['id']])) {
- DI::config()->set('system', 'last_worker_execution', DateTimeFormat::utcNow());
+ DI::keyValue()->set('last_worker_execution', DateTimeFormat::utcNow());
}
self::$db_duration = (microtime(true) - $stamp);
self::$db_duration_write += (microtime(true) - $stamp);
$duration = max($start, $end) - min($start, $end);
// Quit when the last cron execution had been after the previous window
- $last_cron = DI::config()->get('system', 'last_cron_daily');
+ $last_cron = DI::keyValue()->get('last_cron_daily');
if ($last_cron + $duration > time()) {
Logger::info('The Daily cron had been executed recently', ['last' => date(DateTimeFormat::MYSQL, $last_cron), 'start' => date('H:i:s', $start), 'end' => date('H:i:s', $end)]);
return false;
}
// Check every minute if the daemon is running
- if (DI::config()->get('system', 'last_daemon_check', 0) + 60 > time()) {
+ if ((DI::keyValue()->get('last_daemon_check') ?? 0) + 60 > time()) {
return;
}
- DI::config()->set('system', 'last_daemon_check', time());
+ DI::keyValue()->set('last_daemon_check', time());
$pidfile = DI::config()->get('system', 'pidfile');
if (empty($pidfile)) {
$warningtext[] = DI::l10n()->t('The last update failed. Please run "php bin/console.php dbstructure update" from the command line and have a look at the errors that might appear. (Some of the errors are possibly inside the logfile.)');
}
- $last_worker_call = DI::config()->get('system', 'last_worker_execution', false);
+ $last_worker_call = DI::keyValue()->get('last_worker_execution') ?? false;
if (!$last_worker_call) {
$warningtext[] = DI::l10n()->t('The worker was never executed. Please check your database structure!');
} elseif ((strtotime(DateTimeFormat::utcNow()) - strtotime($last_worker_call)) > 60 * 60) {
{
$a = DI::app();
- $last = DI::config()->get('system', 'last_cron');
+ $last = DI::keyValue()->get('last_cron');
$poll_interval = intval(DI::config()->get('system', 'cron_interval'));
Worker::add(Worker::PRIORITY_LOW, 'PostUpdate');
// Hourly cron calls
- if (DI::config()->get('system', 'last_cron_hourly', 0) + 3600 < time()) {
+ if ((DI::keyValue()->get('last_cron_hourly') ?? 0) + 3600 < time()) {
// Update trending tags cache for the community page
// Clear cache entries
Worker::add(Worker::PRIORITY_LOW, 'ClearCache');
- DI::config()->set('system', 'last_cron_hourly', time());
+ DI::keyValue()->set('last_cron_hourly', time());
}
// Daily maintenance cron calls
// Resubscribe to relay servers
Relay::reSubscribe();
- DI::config()->set('system', 'last_cron_daily', time());
+ DI::keyValue()->set('last_cron_daily', time());
}
Logger::notice('end');
- DI::config()->set('system', 'last_cron', time());
+ DI::keyValue()->set('last_cron', time());
}
/**
return;
}
- $now = (int)DI::config()->get('system', 'last-directory-sync', 0);
+ $now = (int)(DI::keyValue()->get('last-directory-sync') ?? 0);
Logger::info('Synchronization started.', ['now' => $now, 'directory' => $directory]);
$result = Contact::addByUrls($contacts['results']);
$now = $contacts['now'] ?? 0;
- DI::config()->set('system', 'last-directory-sync', $now);
+ DI::keyValue()->set('last-directory-sync', $now);
Logger::info('Synchronization ended', ['now' => $now, 'count' => $result['count'], 'added' => $result['added'], 'updated' => $result['updated'], 'unchanged' => $result['unchanged'], 'directory' => $directory]);
}
function update_1505()
{
- $postUpdateEntries = DBA::selectToArray('config', ['k', 'v'], ["`k` LIKE ?", "post_update_%"]);
+ $conditions = [
+ "(`k` LIKE ?) OR (`k` = ?) OR (`cat` = ? AND `k` LIKE ?)",
+ "post_update_%",
+ "worker_last_cleaned",
+ "system",
+ "last%"
+ ];
+
+ $postUpdateEntries = DBA::selectToArray('config', ['k', 'v'], $conditions);
foreach ($postUpdateEntries as $postUpdateEntry) {
DI::keyValue()->set($postUpdateEntry['k'], $postUpdateEntry['v']);
}
- return DBA::delete('config', ["`k` LIKE ?", "post_update_%"]) ? Update::SUCCESS : Update::FAILED;
+ return DBA::delete('config', $conditions) ? Update::SUCCESS : Update::FAILED;
}