[Svn] r4283 - branches/devel-addressbook/program/include

trac at roundcube.net trac at roundcube.net
Sat Nov 27 17:36:24 CET 2010


Author: thomasb
Date: 2010-11-27 10:36:24 -0600 (Sat, 27 Nov 2010)
New Revision: 4283

Modified:
   branches/devel-addressbook/program/include/rcmail.php
Log:
Make sure to call rcube_addressbook::close() on every instance ever created

Modified: branches/devel-addressbook/program/include/rcmail.php
===================================================================
--- branches/devel-addressbook/program/include/rcmail.php	2010-11-27 15:49:04 UTC (rev 4282)
+++ branches/devel-addressbook/program/include/rcmail.php	2010-11-27 16:36:24 UTC (rev 4283)
@@ -114,7 +114,7 @@
   public $comm_path = './';
 
   private $texts;
-  private $books = array();
+  private $address_books = array();
 
 
   /**
@@ -350,8 +350,8 @@
     }
 
     // add to the 'books' array for shutdown function
-    if (!in_array($contacts, $this->books))
-      $this->books[] = $contacts;
+    if (!isset($this->address_books[$id]))
+      $this->address_books[$id] = $contacts;
 
     return $contacts;
   }
@@ -397,14 +397,15 @@
     $plugin = $this->plugins->exec_hook('addressbooks_list', array('sources' => $list));
     $list = $plugin['sources'];
 
-    if ($writeable && !empty($list)) {
-      foreach ($list as $idx => $item) {
-        if ($item['readonly']) {
+    foreach ($list as $idx => $item) {
+      // register source for shutdown function
+      if (!is_object($this->address_books[$item['id']]))
+        $this->address_books[$item['id']] = $item;
+      // remove from list if not writeable as requested
+      if ($writeable && $item['readonly'])
           unset($list[$idx]);
-        }
-      }
     }
-
+    
     return $list;
   }
 
@@ -1066,9 +1067,12 @@
     if (is_object($this->smtp))
       $this->smtp->disconnect();
 
-    foreach ($this->books as $book)
-      if (is_object($book))
+    foreach ($this->address_books as $book) {
+      if (!is_object($book))  // maybe an address book instance wasn't fetched using get_address_book() yet
+        $book = $this->get_address_book($book['id']);
+      if (is_a($book, 'rcube_addressbook'))
         $book->close();
+    }
 
     // before closing the database connection, write session data
     if ($_SERVER['REMOTE_ADDR'])

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



More information about the Svn mailing list