fix: Error when posting server without server_state.
This commit is contained in:
@@ -59,20 +59,21 @@ class API_servers extends API
|
||||
{
|
||||
|
||||
# if the server_state that is posted is 'deleted' check if the current server state is 'new' if so, delete it perm.
|
||||
if ($this->data['server_state'] == 'deleted') {
|
||||
$stmt = $GLOBALS['pdo']->prepare("SELECT server_state FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
||||
$stmt->execute([$this->data['server_vm_id']]);
|
||||
if (isset($this->data['server_state'])) {
|
||||
if ($this->data['server_state'] == 'deleted') {
|
||||
$stmt = $GLOBALS['pdo']->prepare("SELECT server_state FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
||||
$stmt->execute([$this->data['server_vm_id']]);
|
||||
|
||||
if ($stmt->fetch()) {
|
||||
$deleteStmt = $GLOBALS['pdo']->prepare("DELETE FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
||||
$deleteStmt->execute([$this->data['server_vm_id']]);
|
||||
return;
|
||||
if ($stmt->fetch()) {
|
||||
$deleteStmt = $GLOBALS['pdo']->prepare("DELETE FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
||||
$deleteStmt->execute([$this->data['server_vm_id']]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->data['company_uuid'])) {
|
||||
if (strlen($this->data['company_uuid']) == 0) {
|
||||
$this->data['company_uuid'] = NULL;
|
||||
if (isset($this->data['company_uuid'])) {
|
||||
if (strlen($this->data['company_uuid']) == 0) {
|
||||
$this->data['company_uuid'] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user