A client of mine had a site with some really, really drawn out form wizards for anonymous users. We were getting reports of people losing their data when they accidentally closed their browser, got tired, etc. and we had reasons for not allowing people to create an account on the site until these forms were completed.

I'm not sure if there's enough use cases for this patch to be committed, but it basically allows developers to use their own session ID system for object caching. I used Sessions API for the functionality needed so that visitors can close their browser and come back later, but there may be other ways to do it.

Anyway, I'm just throwing this patch out there in case someone else finds it useful.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Status: Active » Needs review

I actually think this is a good idea; the built-in relianceon the session id is useful but it is not entirely ideal and sometimes it is not what is wanted.

Marking needs review, but the idea is sound and will check out the code when I have more time.

merlinofchaos’s picture

Status: Needs review » Needs work
+  // Set $sid if it hasn't been set yet.
+  $sid = (!$sid ? session_id() : $sid);
+

I think this is cleaner:

if (!isset($sid)) {
  $sid = session_id();
}

More lines, but I think easier to read.

Rest of patch looks good. Should be an easy reroll.

jludwig’s picture

Here's the new patch. I removed the comments because you're right, the longer version is easier to read and pretty self-explanatory.

On a side note, to get the site to work how they wanted it to work the way these clients needed it to, I ended up patching ctools_object_cache_clean here: #1509090: Allow developers to customize minimum age of ctools_object_cache_clean()

It pretty much doubles the code size, may be overly complex, and still needs some work for a feature that might not even be used all that often, but I thought I would run it by you to see if it's worth it to continue on it and whether I should try to think of a way that is more clever for that functionality.

jludwig’s picture

Status: Needs work » Needs review

Woops, I forgot to change the status.

merlinofchaos’s picture

Status: Needs review » Fixed

I went ahead and bumped the API version to 2.0.7 and updated API.txt.

It occurs to me that help/object-cache should probably be updated, though honestly that needs to be rewritten anyway.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.