Hi there,

I have installed image fupload and is working fine when I don't use memcache session handling. I am using memcache session handling to gain some performance gains. I am getting Upload Error 403 when I enable the memcache session handling. I tried to comment out all the lines in the code where it was refering to the drupal session table but still the error pops up.

Thanks
Mir Owais.

CommentFileSizeAuthor
#3 image_fupload-memcache.patch1.09 KBmavimo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vincentw’s picture

Version: 6.x-2.0-rc2 » 6.x-3.0-rc2
Status: Active » Needs work

In image_fupload.module line 137-139 ish, the module goes to the "session" table to validate the user's session.

Assuming you've set up memcache to handle sessions according to memcache's readme.txt...

In image_fupload.module, replace:

$result = db_query("SELECT * FROM {sessions} WHERE sid = '%s' AND hostname = '%s' LIMIT 1", $sid, ip_address());
$upload_user = db_fetch_object($result);

With:

$current_session = dmemcache_get($sid, 'session');
$current_user = dmemcache_get($current_session->uid, 'users');
$upload_user->uid = $current_user->uid;
$upload_user->sid = $current_session->sid;
$upload_user->hostname = $current_session->hostname;
$upload_user->timestamp = $current_session->timestamp;
$upload_user->cache = 0;
$upload_user->session = $current_session->session;

This will look up user and session variables from memcache instead of the database. This also means if memcache stops working this won't work either.

I also don't know if there are any security issues.

Hopefully someone can write a proper patch at least.

grandcat’s picture

Status: Needs work » Active

There's no patch at the moment.

mavimo’s picture

Status: Active » Needs review
Issue tags: +memcache, +session, +image fupload
FileSize
1.09 KB

Into attachment you can find a patch to use image_fupload with memcache module.

vincentw’s picture

Thanks!

frankcarey’s picture

Question for you all: Is there no abstraction layer for using sessions making the code the same for memcache or not? If not is there a reason we can't use a simple if statement so that there is no reason to patch? Thanks!

mavimo’s picture

@frankcarey: memcache do not support search into query, is key-value DB, and you must load complete sessions data and after check if user can upload file and validate post data. When mysql you can use a query to select correct information you require.

I can try to remove if, but i'm not sure is a good idea :| (perfomance go down).

frankcarey’s picture

@mavimo I should have looked at the actual patch. What I was suggesting is TO use an if (test if memcache was running). It looks like you've already integrated that into your code though, so should be good. I'll have some time to test this out next week.

mavimo’s picture

@frankcarey: any news from your test?

sdelbosc’s picture

Just to track the issue...

geerlingguy’s picture

Subscribe. Having session issues behind a corporate firewall/proxy in FireFox.

mrwhizkid’s picture

I can confirm that the patch from #3 works for memcache sessions.

Thanks!

3dloco’s picture

#3 works very well for me too...thanks!

jjemmett’s picture

Status: Needs review » Reviewed & tested by the community

works for me.