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
This commit is contained in:
Dag 2023-07-20 19:11:13 +02:00 committed by GitHub
parent 663729cf19
commit 0a118310cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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();
}