From 59627ea9efa0c7bd89b02fb4424efa964f38bbb3 Mon Sep 17 00:00:00 2001 From: shimon Date: Sat, 9 Jul 2022 21:24:28 +0300 Subject: [PATCH] logger moved to App::shutdown --- app/controllers/api/avatars.php | 12 ++++++++++++ app/controllers/api/storage.php | 4 ++++ app/controllers/shared/api.php | 1 - app/init.php | 6 ++++-- app/workers/deletes.php | 2 +- composer.lock | 10 +++++----- docker-compose.yml | 2 +- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index d343cb0e9..fad4fc232 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -68,6 +68,9 @@ $avatarCallback = function (string $type, string $code, int $width, int $height, $data = $image->output($output, $quality); + App::setResource('cacheKey', fn () => $key); + App::setResource('cachePath', fn () => 'app-0'); + $cache->save($key, $data); $response @@ -191,6 +194,9 @@ App::get('/v1/avatars/image') $data = $image->output($output, $quality); + App::setResource('cacheKey', fn () => $key); + App::setResource('cachePath', fn () => 'app-0'); + $cache->save($key, $data); $response @@ -321,6 +327,9 @@ App::get('/v1/avatars/favicon') throw new Exception('Favicon not found', 404, Exception::AVATAR_ICON_NOT_FOUND); } + App::setResource('cacheKey', fn () => $key); + App::setResource('cachePath', fn () => 'app-0'); + $cache->save($key, $data); return $response @@ -344,6 +353,9 @@ App::get('/v1/avatars/favicon') $data = $image->output($output, $quality); + App::setResource('cacheKey', fn () => $key); + App::setResource('cachePath', fn () => 'app-0'); + $cache->save($key, $data); $response diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 636e521cc..7cab91723 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -970,6 +970,10 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $cache->save($key, $data); + App::setResource('cacheKey', fn () => $key); + App::setResource('cachePath', fn () => 'app-' . $project->getId()); + + $usage ->setParam('storage.files.read', 1) ->setParam('bucketId', $bucketId) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 1c9c472b0..3f5f2277d 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -237,7 +237,6 @@ App::shutdown(function (App $utopia, Request $request, Response $response, Docum $database->trigger(); } - $route = $utopia->match($request); if ( App::getEnv('_APP_USAGE_STATS', 'enabled') == 'enabled' diff --git a/app/init.php b/app/init.php index bac8bb089..489170ca6 100644 --- a/app/init.php +++ b/app/init.php @@ -86,8 +86,8 @@ const APP_LIMIT_COMPRESSION = 20000000; //20MB const APP_LIMIT_ARRAY_PARAMS_SIZE = 100; // Default maximum of how many elements can there be in API parameter that expects array value const APP_LIMIT_ARRAY_ELEMENT_SIZE = 4096; // Default maximum length of element in array parameter represented by maximum URL length. const APP_LIMIT_SUBQUERY = 1000; -const APP_CACHE_BUSTER = 402; -const APP_VERSION_STABLE = '0.15.2'; +const APP_CACHE_BUSTER = 400; +const APP_VERSION_STABLE = '0.15.0'; const APP_DATABASE_ATTRIBUTE_EMAIL = 'email'; const APP_DATABASE_ATTRIBUTE_ENUM = 'enum'; const APP_DATABASE_ATTRIBUTE_IP = 'ip'; @@ -695,6 +695,8 @@ App::setResource('layout', function ($locale) { return $layout; }, ['locale']); +App::setResource('cacheKey', fn () => ''); +App::setResource('cachePath', fn () => ''); App::setResource('locale', fn() => new Locale(App::getEnv('_APP_LOCALE', 'en'))); // Queues diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 3c7d382f0..c408e2b66 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -149,7 +149,7 @@ class DeletesV1 extends Worker if ($cache->delete($path)) { Console::success('Deleting cache file: ' . $path); } else { - Console::error('**Failed to delete cache file: ' . $path); + Console::error('Failed to delete cache file: ' . $path); } } ); diff --git a/composer.lock b/composer.lock index d33cd3aef..e7fd9c1d8 100644 --- a/composer.lock +++ b/composer.lock @@ -236,16 +236,16 @@ }, { "name": "chillerlan/php-settings-container", - "version": "2.1.3", + "version": "2.1.4", "source": { "type": "git", "url": "https://github.com/chillerlan/php-settings-container.git", - "reference": "125dd573b45ffc7cabecf385986a356ba2c6f602" + "reference": "1beb7df3c14346d4344b0b2e12f6f9a74feabd4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/125dd573b45ffc7cabecf385986a356ba2c6f602", - "reference": "125dd573b45ffc7cabecf385986a356ba2c6f602", + "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/1beb7df3c14346d4344b0b2e12f6f9a74feabd4a", + "reference": "1beb7df3c14346d4344b0b2e12f6f9a74feabd4a", "shasum": "" }, "require": { @@ -296,7 +296,7 @@ "type": "ko_fi" } ], - "time": "2022-03-09T13:18:58+00:00" + "time": "2022-07-05T22:32:14+00:00" }, { "name": "colinmollenhour/credis", diff --git a/docker-compose.yml b/docker-compose.yml index f167863b6..2611f6c7f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -208,7 +208,7 @@ services: volumes: - ./app:/usr/src/code/app - ./src:/usr/src/code/src - # - ./vendor:/usr/src/code/vendor + - ./vendor:/usr/src/code/vendor depends_on: - mariadb - redis