From 485f23b85970e8b3fb559e28a763915f41d4e0d6 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 11 Oct 2012 02:47:40 -0400
Subject: [PATCH] Fix threaded list sorting on PHP < 5.2.9 (#1488748)

---
 program/include/rcube_result_thread.php |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/program/include/rcube_result_thread.php b/program/include/rcube_result_thread.php
index 09fa465..b2325a4 100644
--- a/program/include/rcube_result_thread.php
+++ b/program/include/rcube_result_thread.php
@@ -475,16 +475,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