Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache on Sqlite3 includes NULL character in the value #54082

Open
adamkiss opened this issue Jan 4, 2025 · 1 comment
Open

Cache on Sqlite3 includes NULL character in the value #54082

adamkiss opened this issue Jan 4, 2025 · 1 comment

Comments

@adamkiss
Copy link

adamkiss commented Jan 4, 2025

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
Copy link

github-actions bot commented Jan 6, 2025

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants