Viewing 1 reply thread
  • Author
    Posts
    • #7751
      torarnv
      Member

      I’m using a piklist form with Logged in: false to accept registrations for an event. Due to the rush of registration when the event opens, page-caching is used via W3 Total Cache to limit the number of PHP processes that need to be spun up.

      This presents a problem later on when new registrations are submitted, as Piklist_Validate::check() tries to fetch the previously rendered form via get_transient(), which by that time has expired (after 24 hours).

      The error condition is also hard to detect and work around in user-code, as Piklist_Form::process_form() just returns if save() returns false, without setting any error state that can be picked up elsewhere.

      Even if I aggressively invalidate the cache, say every 5 minutes, there’s still a window of 5 minutes where the page cache is valid, but the transient hits its expiry time, in the worst case just after the page cache has been regenerated by a visit.

      One fix seems to unconditionally do set_transient(), instead of checking false === get_transient(piklist::$prefix . $fields_id)first, which would update the transient timeout. As long as the transient timeout is larger than the cache invalidation expiry time, this should ensure the transient is alive for the duration of any cached form.

    • #7752
      torarnv
      Member

      Technically, a transient can also expire before the timeout, at any time, so the form validation may fail regardless of caching, say if the user spends a bit of time filling out the form.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.