Skip to content

Commit 8064d95

Browse files
xurshudyanXurshudyan
andauthored
Ensure missing-attribute prevention flag is always restored (#57970)
Co-authored-by: Xurshudyan <[email protected]>
1 parent 41abbe2 commit 8064d95

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Illuminate/Database/Eloquent/Model.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,11 +2447,11 @@ public function offsetExists($offset): bool
24472447

24482448
static::$modelsShouldPreventAccessingMissingAttributes = false;
24492449

2450-
$result = ! is_null($this->getAttribute($offset));
2451-
2452-
static::$modelsShouldPreventAccessingMissingAttributes = $shouldPrevent;
2453-
2454-
return $result;
2450+
try {
2451+
return ! is_null($this->getAttribute($offset));
2452+
} finally {
2453+
static::$modelsShouldPreventAccessingMissingAttributes = $shouldPrevent;
2454+
}
24552455
}
24562456

24572457
/**

0 commit comments

Comments
 (0)