From d036c7e70470201141e38bab450f9038e5140acc Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 13 May 2024 15:29:29 +1000 Subject: [PATCH] When decompressing compressed messages, dont barf if we try to decompress the same attribute twice --- app/Casts/CompressedString.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Casts/CompressedString.php b/app/Casts/CompressedString.php index 6089640..918183d 100644 --- a/app/Casts/CompressedString.php +++ b/app/Casts/CompressedString.php @@ -28,7 +28,13 @@ class CompressedString implements CastsAttributes ? stream_get_contents($value) : $value; - return $value ? zstd_uncompress(base64_decode($value)) : ''; + // If we get an error decompressing, it might not be zstd (or its already been done) + try { + return $value ? zstd_uncompress(base64_decode($value)) : ''; + + } catch (\ErrorException $e) { + return $value; + } } /**