Download & Extend

Backport sessions module to D6

Project:Mongodb
Version:6.x-1.x-dev
Component:Session
Category:task
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

Writing to sessions unfortunately takes forever in mysql.

I think it would be awesome if this was ported back to D6.

Comments

#1

Here is my first stab at a 'backport'.

This is for testing and debugging only. I left in some debugging logic I was using in case someone needs to do some debugging on their own.

Some Notes:

- This was developed and tested in a pressflow install. As such it implements and uses some functions that only pressflow has. However, these functions only live in mongodb_session.inc, so in theory this should work with core drupal as well (please test).

- If you want to test this in a pressflow install you will have to apply the included patch which moves all the drupal_session_* functions from bootstrap.inc to session.inc. This allows mongodb_session.inc to override them, since they contain db_query writes. We will need to petition the guys at four kitchens to apply this patch once we are happy with this module.

Enjoy

AttachmentSizeStatusTest resultOperations
sessions2.patch19.91 KBTest request sentNoneView details
pressflow-session.patch.txt13.33 KBIgnored: Check issue status.NoneNone

#2

Status:active» needs work

The patch is too old

#3

Category:feature request» task
Status:needs work» needs review

Attaching my version of the patch. Depends on #1179402: Define REQUEST_TIME for backports for REQUEST_TIME support. Other than REQUEST_TIME, it follows D6 in every aspect: no lazy sessions, https stuff, etc.
I think for Pressflow its better to create separate .inc file

AttachmentSizeStatusTest resultOperations
mongodb_session_1007974.patch15.34 KBTest request sentNoneView details

#4

Better patch

AttachmentSizeStatusTest resultOperations
mongodb_session_1007974.patch15.26 KBTest request sentNoneView details

#5

Status:needs review» needs work

#6

Status:needs work» needs review

Updated patch: no REQUEST_TIME dependency, no tests, variable collection name.
Btw, previous version worked for me without issues.

AttachmentSizeStatusTest resultOperations
mongodb_session_1007974_6.patch9.66 KBTest request sentNoneView details

#7

I wonder whether :

- it makes sense to create this version for core instead of Pressflow: can you really imagine a MongoDB deployment on a non-Pressflow instance ?
- we can have a test suite before committing

#8

I'm using D6 core myself :P

#9

Got errors when i had no session.

My workaround:

$user = mongodb_collection(variable_get('mongodb_session', 'session'))->findOne(array('sid' => $sid));

if($user)
$user = (object)$user;

If this is not changed it tries to get the not set variable $user->uid and throws an exception.

#10

@dob_
You said you are using Pressflow. I wonder how you make this work, because Pressflow has different session functions and stuff (same as D7) and this patch is only for D6

I've encountered "non utf8 string" exceptions with my last patch. So I switched to using MongoBinData

AttachmentSizeStatusTest resultOperations
mongdob_session_1007974_10.patch9.75 KBTest request sentNoneView details

#11

There's a bug in the previous patch: I forgot to unpack binary data for anonymous sessions.

#12

Status:needs review» needs work

#13

Status:needs work» needs review
AttachmentSizeStatusTest resultOperations
mongodb_session_1007974_13.patch9.77 KBIdleFAILED: [[SimpleTest]]: [MySQL] 1 pass(es), 1 fail(s), and 0 exception(es).View details | Re-test

#14

Status:needs review» needs work

The last submitted patch, mongodb_session_1007974_13.patch, failed testing.

#15

Status:needs work» reviewed & tested by the community

The d.o testbot doesn't have mongodb installed so obviously the test fails. I re-ran the test in my local environment with mongodb installed and all tests passed. Furthurmore, this patch seems to work great. Please commit!

#16

Status:reviewed & tested by the community» needs work

I take it all back. This implementation is broken.

It puts the *entire* user object into mongo, then, when the session is instantiated, it does this:

global $user;
$user = $user_from_mongo;

This is bad because it's impossible to update a user without instantiating a session for that user. Expect many things to mysteriously break.

do not use this patch.

#17

AFAIR, the patch doesn't do anything different from the core D6, but I'll double check when I have time.

#18

Yeah, #16 makes sense. Original code gets user object from the user table.

nobody click here