Thanks for the clarification. The sequence of the log entries was a red herring, a distraction. It still bothers me that sess_write() is called twice for one page request. I suspect there's a drupal_goto() involved, courtesy of the FAPI, which introduces a race condition between the first sess_write () and the second sess_read(). It seems like sess_write() should always win, though, unless the database is heavily optimized for reading at the expense of writing. Any thoughts? Nic On May 17, 2006, at 6:55 PM, John VanDyk wrote:
I think you may be confusing two things.
$_SESSION = 'foo';
this statement simply assigns a value to the $_SESSION superglobal. The superglobal is in memory at this point.
sess_write() is called by PHP's built-in session handling code. It is the very last thing called before PHP exits. Within this function, Drupal updates the appropriate database row with the value of $_SESSION.
So the sequence you gave is correct.
Is sess_write() called by the same PHP process that handles page requests?
I'm working with dado to debug node_import.module (see http:// drupal.org/node/63581). node_import.module uses a $_SESSION variable to control the workflow state, which is something I've not seen often.
Simply put, the workflow progresses normally for some people (e.g. dado) and not for others (e.g. me). For me, some variables in $_SESSION are effectively not updated. I say "effectively" because $_SESSION is written twice. The second write uses old values.
At one point, I have the following debugging statements: <?php
watchdog('debug', 'Before'); $_SESSION['node_import'] = $edit; // NOTE: sess_write() calls watchdog('debug', 'Writing'). watchdog('debug', 'After');
?>
The logs consistently show, in reverse chronological order: Writing After Before
What's going on?
Nic