fix: handle missing server_permissions table gracefully
- Wrap ServerPermission queries in try-catch so show/edit don't 500 when the migration hasn't been run yet - Same protection for save calls in store/update (both web and API)
This commit is contained in:
@@ -178,8 +178,12 @@ class ApiController
|
||||
$id = $serverModel->create($input);
|
||||
|
||||
if (!empty($permissions)) {
|
||||
$permModel = new ServerPermission();
|
||||
$permModel->save($id, $permissions);
|
||||
try {
|
||||
$permModel = new ServerPermission();
|
||||
$permModel->save($id, $permissions);
|
||||
} catch (\Throwable $e) {
|
||||
// Table may not exist yet
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->json([
|
||||
@@ -238,8 +242,12 @@ class ApiController
|
||||
$serverModel->update($id, $input);
|
||||
|
||||
if (!empty($permissions)) {
|
||||
$permModel = new ServerPermission();
|
||||
$permModel->save($id, $permissions);
|
||||
try {
|
||||
$permModel = new ServerPermission();
|
||||
$permModel->save($id, $permissions);
|
||||
} catch (\Throwable $e) {
|
||||
// Table may not exist yet
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->json([
|
||||
|
||||
Reference in New Issue
Block a user