From 0a118310cb123460e49778ec74791cb2d0b6ba6f Mon Sep 17 00:00:00 2001 From: Dag Date: Thu, 20 Jul 2023 19:11:13 +0200 Subject: [PATCH] fix(sqlitecache): store blob as blob (#3555) serialize() can return output with null bytes and other non-text data. The prior behavior truncated data which later results in unserialize() errors. This happens when e.g. caching an object with a private field or when caching e.g. a JPEG file (starts with 0xFFD8FFE1) Fixes errors such as e.g.: unserialize(): Error at offset 20 of 24 bytes at caches/SQLiteCache.php line 51 --- caches/SQLiteCache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caches/SQLiteCache.php b/caches/SQLiteCache.php index d7ab1374..92235862 100644 --- a/caches/SQLiteCache.php +++ b/caches/SQLiteCache.php @@ -69,7 +69,7 @@ class SQLiteCache implements CacheInterface $stmt = $this->db->prepare('INSERT OR REPLACE INTO storage (key, value, updated) VALUES (:key, :value, :updated)'); $stmt->bindValue(':key', $this->getCacheKey()); - $stmt->bindValue(':value', $blob); + $stmt->bindValue(':value', $blob, \SQLITE3_BLOB); $stmt->bindValue(':updated', time()); $stmt->execute(); }