Skip to content

Cache on Sqlite3 includes NULL character in the value #54082

@adamkiss

Description

@adamkiss

Laravel Version

11.37.0

PHP Version

8.4.2

Database Driver & Version

Sqlite3 3.43.2 2023-10-10 13:08:14

Description

PHP serialize includes a null character when serializing objects with private properties (Source: PHP.net / Serialize), which SQLite3 doesn't properly support - getting cached values with Laravel somehow works, but the cli command sqlite3, many db browsers and even the .dump command fail to properly output the value from the cache KV store (Source: SQLite3 - Nul characters in strings).

When debugging the error with the unserialisation of the value, I've noticed the Cache class already guards against nul values in Postgresql connections in

if ($this->connection instanceof PostgresConnection && str_contains($result, "\0")) {
, and I think SqliteConnection has to be guarded the same way.

Steps To Reproduce

  1. create new laravel app
  2. set cache_store to database
  3. cache any object with private properties (I'm caching Collection)
  4. observe the database through cli command, db browser, or try to .dump the sqlite file

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions