acquire( trim((string)($data['operation_type'] ?? '')), (int)($data['ttl_minutes'] ?? 120) ); $answer = array_merge($answer, $result); if (empty($result['success'])) { http_response_code(409); // another tab or user holds the lock } } catch (PDOException $e) { error_log('[acquire_op_lock] ' . $e->getMessage()); http_response_code(500); $answer['message'] = 'Database error, please try again.'; } catch (Exception $e) { http_response_code(400); $answer['message'] = $e->getMessage(); } exit(json_encode($answer));