Skip to content

Commit 7e21d0c

Browse files
committed
perf: DatabaseAdapter::updatePolicy return early if not exists
1 parent 440bc22 commit 7e21d0c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Adapters/DatabaseAdapter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,11 @@ public function updatePolicy(string $sec, string $ptype, array $oldRule, array $
256256
foreach($oldRule as $k => $v) {
257257
$instance->where('v' . $k, $v);
258258
}
259-
$instance->first();
259+
$instance = $instance->first();
260+
if (!$instance) {
261+
return;
262+
}
263+
260264
$update = [];
261265
foreach($newPolicy as $k => $v) {
262266
$update['v' . $k] = $v;

0 commit comments

Comments
 (0)