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 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') {
|
if (isset($this->data['server_state'])) {
|
||||||
$stmt = $GLOBALS['pdo']->prepare("SELECT server_state FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
if ($this->data['server_state'] == 'deleted') {
|
||||||
$stmt->execute([$this->data['server_vm_id']]);
|
$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()) {
|
if ($stmt->fetch()) {
|
||||||
$deleteStmt = $GLOBALS['pdo']->prepare("DELETE FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
$deleteStmt = $GLOBALS['pdo']->prepare("DELETE FROM servers WHERE server_vm_id = ? AND server_state = 'new'");
|
||||||
$deleteStmt->execute([$this->data['server_vm_id']]);
|
$deleteStmt->execute([$this->data['server_vm_id']]);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (isset($this->data['company_uuid'])) {
|
||||||
|
if (strlen($this->data['company_uuid']) == 0) {
|
||||||
if (isset($this->data['company_uuid'])) {
|
$this->data['company_uuid'] = NULL;
|
||||||
if (strlen($this->data['company_uuid']) == 0) {
|
}
|
||||||
$this->data['company_uuid'] = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user