PDA

View Full Version : CCK imagefield session issue


rincefire
10-10-2007, 07:34 AM
Hi
I`ve encountered a strange behaviour in vbdrupal (not sure whether it`s a bug)
Imagefield module stores uploaded files data in the $_SESSION variable, until the node is submitted. Before submission, when users preview their work with preview button, uploaded images are lost.
I run several drupal sites with the similar layout, and they don`s have such issue? only the vbdrupal one. Also, i printed the session variable after preview, and on drupal sites it is a populated array with data, but in vbdrupal the array is empty. Session id`s are ok, they are the same right after adding a variable to the session and during preview step.
I think session gets wiped somehow. I`ve had no expierence with vbulletin, so i don`t know much about its session handling, and i`m sure vbdrupal uses vbulletin sessions.
Tried lots of things - explicitly start the sessions in the case autostart doesn`t work, loaded session by id, regardless of the fact id`s are the same - the problem persists, i still get an empty $_SESSION array on preview page.

Any help will be greatly appreciated.

elmuerte
10-17-2007, 03:21 PM
vbDrupal stores the sessions in the same manner as Drupal does, it only changes the way sessions are created (because it will use the same session ID as vbulletin does). But all session data is simply stored in the session table of drupal.

Since status messages are also saved in the session I'm sure they are in working order.

rincefire
11-06-2007, 10:19 AM
After countless workarounds we got stuck again - this session issue affects too many features of drupal, it`s much deeper then just cck.
I did a lot of tinkering\debugging today, and even made an another setup, for testing purposes. sessions are working just fine in it.
the only difference between the setups is the drupal_sessions table. it is populated with session entries in the test database, and is completely empty in the working one. and the worst - session entries don`t get created when there are none - i think they should be. actually, even vbdr_sess_write() is never called.
and then i found this
function sess_write($key, $value) {
return sess_write($key, $value);
}

in sessions.inc. tried to change it to vbdr_sess_write(), no effect.

My vBulletin users were imported via ImpEx, and created in vbdrupal with one large query. It`s not the traditional way, i know, but still, re-creation of user sessions in {sessions} table should be done if there are none.
Maybe i could create session entries manually, but i wonder how hash is generated.

rincefire
11-07-2007, 04:55 AM
Solved it myself.
The problem was, i used MySQLi insted of MySQL for my database. Actually, every cyrillic forum should, because of vBulletin $config['Mysqli']['charset'] variable. In case of vbDrupal it should be set to 'utf8', so threads created from node comments will have sane encoding.
Well, it turned out out sessions are broken because of this part.
global $vbulletin;
if (!is_resource($vbulletin->db->connection_master)) return true;

vBulletin creates objects, not resources when dealing with MySQLi. Changing it to !is_object does the trick.

elmuerte
11-11-2007, 08:11 AM
argh... thanks for finding that issue. I added that check to prevent errors when vBulletin closed the tables at an early stage (this happens in case of vBulletin AJAX processing).

anyway, extended it to cover both cases (mysql and mysqli)