From 8a1b6b06849d099ecafec09098b998a16ec31f1d Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Jan 2025 14:15:35 -0800 Subject: [PATCH 1/2] Add isset check --- app/Observers/AssetObserver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Observers/AssetObserver.php b/app/Observers/AssetObserver.php index 421a93b9d7d..07c3650c001 100644 --- a/app/Observers/AssetObserver.php +++ b/app/Observers/AssetObserver.php @@ -48,7 +48,7 @@ public function updating(Asset $asset) $changed = []; foreach ($asset->getRawOriginal() as $key => $value) { - if ($asset->getRawOriginal()[$key] != $asset->getAttributes()[$key]) { + if (isset($asset->getAttributes()[$key]) && ($asset->getRawOriginal()[$key] != $asset->getAttributes()[$key])) { $changed[$key]['old'] = $asset->getRawOriginal()[$key]; $changed[$key]['new'] = $asset->getAttributes()[$key]; } From 8f512e59415a50dd6fcda586ba18882f767a7043 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 22 Jan 2025 14:28:35 -0800 Subject: [PATCH 2/2] Replace isset with the more appropriate array_key_exists --- app/Observers/AssetObserver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Observers/AssetObserver.php b/app/Observers/AssetObserver.php index 07c3650c001..b44d098123b 100644 --- a/app/Observers/AssetObserver.php +++ b/app/Observers/AssetObserver.php @@ -48,7 +48,7 @@ public function updating(Asset $asset) $changed = []; foreach ($asset->getRawOriginal() as $key => $value) { - if (isset($asset->getAttributes()[$key]) && ($asset->getRawOriginal()[$key] != $asset->getAttributes()[$key])) { + if ((array_key_exists($key, $asset->getAttributes())) && ($asset->getRawOriginal()[$key] != $asset->getAttributes()[$key])) { $changed[$key]['old'] = $asset->getRawOriginal()[$key]; $changed[$key]['new'] = $asset->getAttributes()[$key]; }