From 63d0a0d9d5280492098e23851fe3559f0e31066e Mon Sep 17 00:00:00 2001 From: Lee Watson Date: Wed, 6 Jul 2016 00:10:19 +0100 Subject: [PATCH] [fix] Prevent an edge case with view caching involving two users having the same file hash --- app/Http/Controllers/DownloadController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/DownloadController.php b/app/Http/Controllers/DownloadController.php index e84ada1..3f1f394 100644 --- a/app/Http/Controllers/DownloadController.php +++ b/app/Http/Controllers/DownloadController.php @@ -23,7 +23,7 @@ public function get(Request $request, Upload $upload) } if (!$request->user() || $request->user()->id !== $upload->user_id) { - $cacheKey = sprintf('cached_view:%s:%s', $request->ip(), $upload->hash); + $cacheKey = sprintf('cached_view:%s:%s', $request->ip(), $upload->name); if (!Cache::has($cacheKey)) { Cache::put($cacheKey, 1, 60); DB::table('uploads')->where('id', $upload->id)->increment('views');