running — files were updated, PHP was never reloaded. * applied < running — new files are in place and the update never ran, * so the schema is behind the code. * * Not gated on an edition. `manage_updates` maps to a Community-only * capability, but what code a server is executing is not a feature — it is * a fact about the machine, which is what view_system_info governs. */ class RunningCodeState { public function __construct( private readonly Settings $settings, private readonly Installation $installation, ) {} /** * @return array{reason: string, applied: string, running: string, applied_at: string, install_kind: string}|null */ public function current(): ?array { $applied = $this->settings->get(Setting::AppliedVersion); $running = (string) config('projectsend.version'); // No update has ever been applied through the command: a fresh // install, or one older than the command itself. Nothing to say in // either direction. if (! is_string($applied) || $applied === '' || $running === '') { return null; } $reason = match (true) { version_compare($applied, $running, '>') => 'stale_code', version_compare($applied, $running, '<') => 'pending_update', default => null, }; if ($reason === null) { return null; } $appliedAt = $this->settings->get(Setting::AppliedVersionAt); return [ 'reason' => $reason, 'applied' => $applied, 'running' => $running, 'applied_at' => is_string($appliedAt) ? $appliedAt : '', 'install_kind' => $this->installation->kind()->value, ]; } }