Fix deletion of key/value over HTTP
This commit is contained in:
@ -87,7 +87,7 @@ function http_get(string $url, array $headers) {
|
||||
|
||||
function http_post(string $url, array $headers, ?string $body = null) {
|
||||
global $opts,$http;
|
||||
return $http->post("http://{$opts->server}/{$url}", $headers, $body);
|
||||
return $http->post("http://{$opts->server}/{$url}", $headers, $body??'');
|
||||
}
|
||||
|
||||
function action_get(object $opts) {
|
||||
@ -140,7 +140,7 @@ function action_purge(object $opts) {
|
||||
if (!$collection) {
|
||||
exit_error("Missing collection. Expected: purge {collection}");
|
||||
}
|
||||
http_post($collection."/delete", [], null)->then(
|
||||
http_post($collection."/purge", [], null)->then(
|
||||
function ($response) {
|
||||
echo $response->getBody()->getContents();
|
||||
},
|
||||
|
@ -113,7 +113,6 @@ class Daemon
|
||||
return Response::json([ 'error' => "Invalid request method" ]);
|
||||
}
|
||||
try {
|
||||
$ids = json_decode($request->getBody()->getContents(), true);
|
||||
$this->opCollectionPurge($collectionName);
|
||||
} catch (\Exception $e) {
|
||||
return Response::json([ 'error' => "No such collection" ])->withStatus(404);
|
||||
@ -155,7 +154,7 @@ class Daemon
|
||||
try {
|
||||
$collection = $this->db->getCollection($collectionName);
|
||||
foreach ($ids as $id) {
|
||||
if (is_int($id)) {
|
||||
if (intval($id) > 0) {
|
||||
$collection->deleteValue(intval($id));
|
||||
} else {
|
||||
$collection->deleteKey($id);
|
||||
|
Reference in New Issue
Block a user