From 070b8e9f7144d3f517c68356eacdf3e96484be06 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 17 Oct 2012 04:36:45 -0400
Subject: [PATCH] Fix the fix for empty text parts handling (#1488757)

---
 program/include/rcube_result_thread.php |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/program/include/rcube_result_thread.php b/program/include/rcube_result_thread.php
index e93423e..b939f67 100644
--- a/program/include/rcube_result_thread.php
+++ b/program/include/rcube_result_thread.php
@@ -7,7 +7,10 @@
  | This file is part of the Roundcube Webmail client                     |
  | Copyright (C) 2005-2011, The Roundcube Dev Team                       |
  | Copyright (C) 2011, Kolab Systems AG                                  |
- | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | Licensed under the GNU General Public License version 3 or            |
+ | any later version with exceptions for skins & plugins.                |
+ | See the README file for a full license statement.                     |
  |                                                                       |
  | PURPOSE:                                                              |
  |   THREAD response handler                                             |
@@ -61,6 +64,8 @@
         // ...skip unilateral untagged server responses
         for ($i=0, $len=count($data); $i<$len; $i++) {
             if (preg_match('/^ THREAD/i', $data[$i])) {
+                // valid response, initialize raw_data for is_error()
+                $this->raw_data = '';
                 $data[$i] = substr($data[$i], 7);
                 break;
             }
@@ -473,16 +478,18 @@
             $items = explode(self::SEPARATOR_ITEM, $elem);
             $root  = (int) array_shift($items);
 
-            $result[$elem] = $elem;
-            foreach ($items as $item) {
-                list($lv, $id) = explode(self::SEPARATOR_LEVEL, $item);
+            if ($root) {
+                $result[$root] = $root;
+                foreach ($items as $item) {
+                    list($lv, $id) = explode(self::SEPARATOR_LEVEL, $item);
                     $result[$id] = $root;
+                }
             }
         }
 
         // get only unique roots
         $result = array_filter($result); // make sure there are no nulls
-        $result = array_unique($result, SORT_NUMERIC);
+        $result = array_unique($result);
 
         // Re-sort raw data
         $result = array_fill_keys($result, null);

--
Gitblit v1.9.1