[6.x] Fix nocache database driver failing on MySQL with invalid UTF-8#14505
Merged
jasonvarga merged 3 commits into6.xfrom Apr 16, 2026
Merged
[6.x] Fix nocache database driver failing on MySQL with invalid UTF-8#14505jasonvarga merged 3 commits into6.xfrom
jasonvarga merged 3 commits into6.xfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14504.
Problem
Since 6.10.0,
DatabaseSession::cacheRegion()storesserialize($region)directly into theregionLONGTEXT column ofnocache_regions. PHP'sserialize()emits binary content around protected/private property markers (\x00*\x00,\x00ClassName\x00) that is not valid UTF-8. MySQL'sutf8mb4charset rejects these sequences:PostgreSQL and SQLite don't enforce UTF-8 on text columns, so they're unaffected.
Fix
Wrap the serialized string with
base64_encode/base64_decodeinDatabaseSessionso the value written to MySQL is always pure ASCII. This matches the workaround documented in the issue.This was chosen over changing the column type to
binary/blobbecause a schema change would require a new migration for every existing install that has already runstatamic:nocache:migration. The ~33% base64 size overhead is negligible against aLONGTEXTcolumn (4 GB ceiling) and typical region payload sizes.The cache-backed
Sessionpath is unchanged — Redis/memcached/file stores don't enforce UTF-8.