[Svn] r5226 - in trunk/roundcubemail: . program/include program/steps/mail

trac at roundcube.net trac at roundcube.net
Fri Sep 16 19:53:35 CEST 2011


Author: thomasb
Date: 2011-09-16 12:53:35 -0500 (Fri, 16 Sep 2011)
New Revision: 5226

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_json_output.php
   trunk/roundcubemail/program/include/rcube_session.php
   trunk/roundcubemail/program/steps/mail/attachments.inc
   trunk/roundcubemail/program/steps/mail/compose.inc
   trunk/roundcubemail/program/steps/mail/func.inc
   trunk/roundcubemail/program/steps/mail/sendmail.inc
Log:
Fix session race conditions when composing new messages

Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2011-09-16 17:28:19 UTC (rev 5225)
+++ trunk/roundcubemail/CHANGELOG	2011-09-16 17:53:35 UTC (rev 5226)
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix session race conditions when composing new messages
 - Fix encoding of LDAP contacts identifiers (#1488079)
 - jQuery 1.6.4
 - Make date/time format user configurable; drop 'date_today' config option

Modified: trunk/roundcubemail/program/include/rcube_json_output.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_json_output.php	2011-09-16 17:28:19 UTC (rev 5225)
+++ trunk/roundcubemail/program/include/rcube_json_output.php	2011-09-16 17:53:35 UTC (rev 5226)
@@ -219,6 +219,7 @@
      */
     public function send()
     {
+      sleep(6);
         $this->remote_response();
         exit;
     }

Modified: trunk/roundcubemail/program/include/rcube_session.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_session.php	2011-09-16 17:28:19 UTC (rev 5225)
+++ trunk/roundcubemail/program/include/rcube_session.php	2011-09-16 17:53:35 UTC (rev 5226)
@@ -321,9 +321,9 @@
    */
   public function cleanup()
   {
-    // current compose information is stored in $_SESSION['compose'], move it to $_SESSION['compose_data']
-    if ($_SESSION['compose']) {
-      $_SESSION['compose_data'][$_SESSION['compose']['id']] = $_SESSION['compose'];
+    // current compose information is stored in $_SESSION['compose'], move it to $_SESSION['compose_data_<ID>']
+    if ($compose_id = $_SESSION['compose']['id']) {
+      $_SESSION['compose_data_'.$compose_id] = $_SESSION['compose'];
       $this->remove('compose');
     }
   }

Modified: trunk/roundcubemail/program/steps/mail/attachments.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/attachments.inc	2011-09-16 17:28:19 UTC (rev 5225)
+++ trunk/roundcubemail/program/steps/mail/attachments.inc	2011-09-16 17:53:35 UTC (rev 5226)
@@ -25,7 +25,7 @@
 }
 
 $COMPOSE_ID = get_input_value('_id', RCUBE_INPUT_GPC);
-$_SESSION['compose'] = $_SESSION['compose_data'][$COMPOSE_ID];
+$_SESSION['compose'] = $_SESSION['compose_data_'.$COMPOSE_ID];
 
 if (!$_SESSION['compose']) {
   die("Invalid session var!");

Modified: trunk/roundcubemail/program/steps/mail/compose.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/compose.inc	2011-09-16 17:28:19 UTC (rev 5225)
+++ trunk/roundcubemail/program/steps/mail/compose.inc	2011-09-16 17:53:35 UTC (rev 5226)
@@ -29,7 +29,7 @@
 $MESSAGE = NULL;
 
 $COMPOSE_ID = get_input_value('_id', RCUBE_INPUT_GET);
-$_SESSION['compose'] = $_SESSION['compose_data'][$COMPOSE_ID];
+$_SESSION['compose'] = $_SESSION['compose_data_'.$COMPOSE_ID];
 
 // Nothing below is called during message composition, only at "new/forward/reply/draft" initialization or
 // if a compose-ID is given (i.e. when the compose step is opened in a new window/tab).
@@ -39,7 +39,7 @@
   if ($COMPOSE_ID)
     raise_error(array('code' => 500, 'type' => 'php',
       'file' => __FILE__, 'line' => __LINE__,
-      'message' => "Invalid session"), true, true);
+      'message' => "Invalid compose ID"), true, true);
 
   $_SESSION['compose'] = array(
     'id' => uniqid(mt_rand()),

Modified: trunk/roundcubemail/program/steps/mail/func.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/func.inc	2011-09-16 17:28:19 UTC (rev 5225)
+++ trunk/roundcubemail/program/steps/mail/func.inc	2011-09-16 17:53:35 UTC (rev 5226)
@@ -1430,12 +1430,12 @@
  */
 function rcmail_compose_cleanup($id)
 {
-  if (!isset($_SESSION['compose_data'][$id]))
+  if (!isset($_SESSION['compose_data_'.$id]))
     return;
 
   $rcmail = rcmail::get_instance();
   $rcmail->plugins->exec_hook('attachments_cleanup', array('group' => $id));
-  unset($_SESSION['compose_data'][$id]);
+  $rcmail->session->remove('compose_data_'.$id);
 }
 
 

Modified: trunk/roundcubemail/program/steps/mail/sendmail.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/sendmail.inc	2011-09-16 17:28:19 UTC (rev 5225)
+++ trunk/roundcubemail/program/steps/mail/sendmail.inc	2011-09-16 17:53:35 UTC (rev 5226)
@@ -27,7 +27,7 @@
 $savedraft = !empty($_POST['_draft']) ? true : false;
 
 $COMPOSE_ID = get_input_value('_id', RCUBE_INPUT_GPC);
-$_SESSION['compose'] = $_SESSION['compose_data'][$COMPOSE_ID];
+$_SESSION['compose'] = $_SESSION['compose_data_'.$COMPOSE_ID];
 
 /****** checks ********/
 

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list