From db246ffc452114d5293aaca79f4b4b7a36622085 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 18 Oct 2021 10:09:03 +0200 Subject: [PATCH] Fix CLI encoding of JSON objects --- app/account.php | 2 +- app/database.php | 4 ++-- app/functions.php | 4 ++-- app/users.php | 2 +- install.sh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/account.php b/app/account.php index 993bf49..991dbe8 100644 --- a/app/account.php +++ b/app/account.php @@ -170,7 +170,7 @@ $path = str_replace([], [], '/account/prefs'); $params = []; /** Body Params */ - $params['prefs'] = $prefs; + $params['prefs'] = \json_decode($prefs); $response = $client->call(Client::METHOD_PATCH, $path, [ 'content-type' => 'application/json', ], $params); diff --git a/app/database.php b/app/database.php index af13372..47ea8b6 100644 --- a/app/database.php +++ b/app/database.php @@ -218,7 +218,7 @@ $path = str_replace(['{collectionId}'], [$collectionId], '/database/collections/{collectionId}/documents'); $params = []; /** Body Params */ - $params['data'] = $data; + $params['data'] = \json_decode($data); $params['read'] = !is_array($read) ? array($read) : $read; $params['write'] = !is_array($write) ? array($write) : $write; $params['parentDocument'] = $parentDocument; @@ -267,7 +267,7 @@ $path = str_replace(['{collectionId}', '{documentId}'], [$collectionId, $documentId], '/database/collections/{collectionId}/documents/{documentId}'); $params = []; /** Body Params */ - $params['data'] = $data; + $params['data'] = \json_decode($data); $params['read'] = !is_array($read) ? array($read) : $read; $params['write'] = !is_array($write) ? array($write) : $write; $response = $client->call(Client::METHOD_PATCH, $path, [ diff --git a/app/functions.php b/app/functions.php index 8cac7f4..a860906 100644 --- a/app/functions.php +++ b/app/functions.php @@ -95,7 +95,7 @@ $params['name'] = $name; $params['execute'] = !is_array($execute) ? array($execute) : $execute; $params['runtime'] = $runtime; - $params['vars'] = $vars; + $params['vars'] = \json_decode($vars); $params['events'] = !is_array($events) ? array($events) : $events; $params['schedule'] = $schedule; $params['timeout'] = (int)$timeout; @@ -146,7 +146,7 @@ /** Body Params */ $params['name'] = $name; $params['execute'] = !is_array($execute) ? array($execute) : $execute; - $params['vars'] = $vars; + $params['vars'] = \json_decode($vars); $params['events'] = !is_array($events) ? array($events) : $events; $params['schedule'] = $schedule; $params['timeout'] = (int)$timeout; diff --git a/app/users.php b/app/users.php index a42f76f..ddb16f9 100644 --- a/app/users.php +++ b/app/users.php @@ -230,7 +230,7 @@ $path = str_replace(['{userId}'], [$userId], '/users/{userId}/prefs'); $params = []; /** Body Params */ - $params['prefs'] = $prefs; + $params['prefs'] = \json_decode($prefs); $response = $client->call(Client::METHOD_PATCH, $path, [ 'content-type' => 'application/json', ], $params); diff --git a/install.sh b/install.sh index 370425e..965b07a 100644 --- a/install.sh +++ b/install.sh @@ -24,7 +24,7 @@ APPWRITE_EXECUTABLE_NAME=appwrite APPWRITE_EXECUTABLE_FILEPATH="$APPWRITE_INSTALL_DIR/$APPWRITE_EXECUTABLE_NAME" # Appwrite CLI temp name -APPWRITE_TEMP_NAME=temp +APPWRITE_TEMP_NAME=temp-$(date +%s) # Appwrite CLI image name APPWRITE_CLI_IMAGE_NAME=appwrite/cli