Support » Plugin: CMB2 » cmb2_save_field has old data when memcached turned on

  • I’m currently hooking into cmb2_save_field_{$field_id} to perform an operation when that custom field changes. This works great unless memcached is turned on (provided by SiteGround) in which case my function receives the OLD field value instead of the new one. Any ideas on how to get the correct field value with memcached?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Justin Sternberg

    (@jtsternberg)

    Hmm that sounds like a problem with the memcache implementation. There should no reason it would pass the old value. I’ve used CMB2 for many projects where object cache was enabled, and have not had that issue.

    Thread Starter Yaron Guez

    (@yguez)

    Have you experimented with memcached specifically? SiteGround is a pretty massive hosting platform so a memcached implementation error would be far reaching. I’m not saying that’s not the case, but the more proof or information I could provide them to help track down the problem would be helpful.

    Thread Starter Yaron Guez

    (@yguez)

    Some additional details that might be helpful:
    – within function, the $_POST data has the correct new value, but the $field->value is the old value.
    – Fetching the field data with get_post_meta within the function also loads the old data
    – Fetching the title of the post yields the CORRECT title. So the caching bug only affects custom fields.
    – The new field does get persisted to the database and does show up correctly in the dashboard after saving. It’s just this hook that has the old data. On the next change of that field to another value, the last value flows into the function again.

    SiteGround would be receptive to fixing any issues with their memcached implementation if I can illustrate that the issue lies with them and not CMB2. Have you tested the cmb2_save_field hook with memcached before?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘cmb2_save_field has old data when memcached turned on’ is closed to new replies.