From 8d5583f0c6794abedcf1fd148131a43ca4251d8f Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Wed, 22 May 2024 19:16:34 +0000 Subject: [PATCH 1/2] fix(cache): fix invalid cache document id The document ID should not have special characters like "*" or it will cause problems with things like cursor based pagination which is done in migrations. We did have the cache buster inside the md5 call before, but when the usage code was reverted and whatnot, the change wasn't added back properly. Related: https://github.com/appwrite/appwrite/issues/7887 --- app/controllers/shared/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 1afd6b652e..645236cc9d 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -666,7 +666,7 @@ App::shutdown() $resourceType = $parseLabel($pattern, $responsePayload, $requestParams, $user); } - $key = md5($request->getURI() . '*' . implode('*', $request->getParams())) . '*' . APP_CACHE_BUSTER; + $key = md5($request->getURI() . '*' . implode('*', $request->getParams()) . '*' . APP_CACHE_BUSTER); $signature = md5($data['payload']); $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); $accessedAt = $cacheLog->getAttribute('accessedAt', ''); From 9db92698dc8369522c82d3a602e52819a80b1e23 Mon Sep 17 00:00:00 2001 From: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> Date: Wed, 22 May 2024 23:23:16 +0000 Subject: [PATCH 2/2] fix(cache): use the same cache key when loading and saving files --- app/controllers/shared/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 645236cc9d..d8899822d8 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -411,7 +411,7 @@ App::init() $useCache = $route->getLabel('cache', false); if ($useCache) { - $key = md5($request->getURI() . implode('*', $request->getParams()) . '*' . APP_CACHE_BUSTER); + $key = md5($request->getURI() . '*' . implode('*', $request->getParams()) . '*' . APP_CACHE_BUSTER); $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); $cache = new Cache( new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId())