mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Store system first boot date in the database explicitly (#639)
The first plugin version record is unreliable, especially as plugins are added and removed; so this commit stores the first boot date in the database explicitly by using a database migration.
This commit is contained in:
parent
916151f20c
commit
5cbf1ec653
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Winter\Storm\Database\Updates\Migration;
|
||||
use Carbon\Carbon;
|
||||
use System\Models\Parameter;
|
||||
use System\Models\PluginVersion;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$appBirthday = Parameter::get('system::app.birthday');
|
||||
if ($appBirthday) {
|
||||
// Return early if the birthday has already been set
|
||||
return;
|
||||
}
|
||||
|
||||
$firstPluginCreated = PluginVersion::orderBy('created_at')
|
||||
->first()
|
||||
?->created_at;
|
||||
|
||||
$appBirthday = $firstPluginCreated ?: Carbon::now();
|
||||
|
||||
Parameter::set('system::app.birthday', $appBirthday);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
};
|
@ -11,7 +11,6 @@ use Backend\Classes\ReportWidgetBase;
|
||||
use Backend\Models\User;
|
||||
use System\Models\EventLog;
|
||||
use System\Models\RequestLog;
|
||||
use System\Models\PluginVersion;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
@ -69,8 +68,7 @@ class Status extends ReportWidgetBase
|
||||
$this->vars['requestLog'] = RequestLog::count();
|
||||
$this->vars['requestLogMsg'] = LogSetting::get('log_requests', false) ? false : true;
|
||||
|
||||
// TODO: Store system boot date in `Parameter`
|
||||
$this->vars['appBirthday'] = PluginVersion::orderBy('created_at')->first()?->created_at;
|
||||
$this->vars['appBirthday'] = Parameter::get('system::app.birthday');
|
||||
}
|
||||
|
||||
public function onLoadWarningsForm()
|
||||
|
Loading…
x
Reference in New Issue
Block a user