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

(dev/core#174) civicrm_cache - Allow storage of binary data #12354

Merged
merged 2 commits into from
Jun 26, 2018

Conversation

totten
Copy link
Member

@totten totten commented Jun 22, 2018

Overview

In working on a PSR-16 provider based on the civicrm_cache table, the compliance test suite revealed that civicrm_cache.data was unable to store binary information. The cache is more useful if it can store binary data...

Before

  • civicrm_cache.data is a MySQL longtext column storing the output of serialize($data).

After

  • civicrm_cache.data is a MySQL longtext column storing the output of base64_encode(serialize($data)) (or, if you've just upgraded, possibly serialize($data)).

Technical Details

  • The serialize format is not designed for transmission over strictly textual media. It's meant to differentiate among PHP data-types(eg array vs string vs int). If a string has binary content, then it's still binary content.
  • The output of serialize() and base64_encode() are quite distinctive. Serialize makes heavy use of punctuation (;:{}), whereas base64 is dense alphanumeric (a-zA-Z0-9+/). We use this to pre-emptively deal with any weird edge-cases mixing new logic with old content (e.g. reading cached data in the old format in a pre-upgrade environment).
  • This replaces (dev/core#174) civicrm_cache - Allow storage of binary data #12350. In testing some other work on top of (dev/core#174) civicrm_cache - Allow storage of binary data #12350, I encountered some character-set issues with using the binary column.

@civibot
Copy link

civibot bot commented Jun 22, 2018

(Standard links)

@totten totten changed the title (dev/core#174) civicrm_cache - Allow storage of binary data #12350 (dev/core#174) civicrm_cache - Allow storage of binary data Jun 22, 2018
@totten totten force-pushed the master-cache-b64 branch from 4f4890b to 3c643fe Compare June 22, 2018 03:22
@colemanw colemanw merged commit 5db1add into civicrm:master Jun 26, 2018
@totten totten deleted the master-cache-b64 branch June 27, 2018 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants