Don't use query cache, query building is not that expensive.
authorJan Schneider <jan@horde.org>
Wed, 5 Jan 2011 15:57:38 +0000 (16:57 +0100)
committerJan Schneider <jan@horde.org>
Wed, 5 Jan 2011 15:58:13 +0000 (16:58 +0100)
If really necessary this should be implemented as an instance cache, not a
static cache. Fixes failing pgsql unit test.

framework/Share/lib/Horde/Share/Sql/Hierarchical.php

index 849f0db..9ba3678 100644 (file)
@@ -166,17 +166,11 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
                                      $attributes = null, $parent = null,
                                      $allLevels = true)
     {
-        static $criteria = array();
-
         if (is_object($parent)) {
             $parent_id = $parent->getId();
         } else {
             $parent_id = $parent;
         }
-        $key = hash('sha1', serialize(array($userid, $perm, $parent_id, $allLevels, $attributes)));
-        if (isset($criteria[$key])) {
-            return $criteria[$key];
-        }
 
         $query = ' FROM ' . $this->_table . ' s ';
         $where = '';
@@ -264,17 +258,15 @@ class Horde_Share_Sql_Hierarchical extends Horde_Share_Sql
             $where_parent = "(s.share_parents = '' OR s.share_parents IS NULL)";
         }
 
-        if (empty($where_parent)) {
-            $criteria[$key] = $query . (!empty($where) ? ' WHERE ' . $where : '');
-        } else {
-            if (!empty($where)) {
-                $criteria[$key] = $query . ' WHERE (' . $where . ') AND ' . $where_parent;
+        if (!empty($where_parent)) {
+            if (empty($where)) {
+                $where = $where_parent;
             } else {
-                $criteria[$key] = $query . ' WHERE ' . $where_parent;
+                $where = '(' . $where . ') AND ' . $where_parent;
             }
         }
 
-        return $criteria[$key];
+        return $query . ' WHERE ' . $where;
     }
 
     /**