fix: use wasChanged() instead of isDirty() in updated hook

Critical Bug Fix:
- isDirty() always returns false in the updated() hook
- Changes are already persisted when updated() runs
- wasChanged() correctly tracks what was modified during save

Affected Code:
- helper_version check: Now properly triggers PullHelperImageJob
- fqdn check: Now properly clears TrustHosts cache

Impact:
 Cache invalidation now works when FQDN changes
 Helper image updates now trigger correctly
 Security fix cache is properly cleared on config changes

This also fixes an existing bug where helper_version updates
never triggered the PullHelperImageJob dispatch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai 2025-10-15 22:20:52 +02:00
parent 5ce0670ca4
commit 3c799df887

View file

@ -35,7 +35,7 @@ class InstanceSettings extends Model
protected static function booted(): void
{
static::updated(function ($settings) {
if ($settings->isDirty('helper_version')) {
if ($settings->wasChanged('helper_version')) {
Server::chunkById(100, function ($servers) {
foreach ($servers as $server) {
PullHelperImageJob::dispatch($server);
@ -44,7 +44,7 @@ protected static function booted(): void
}
// Clear trusted hosts cache when FQDN changes
if ($settings->isDirty('fqdn')) {
if ($settings->wasChanged('fqdn')) {
\Cache::forget('instance_settings_fqdn_host');
}
});