<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>lots of &quot;DB Error: unknown error: INSERT INTO&quot; when Horde_Cache is enabled</title> 
  <pubDate>Fri, 10 Apr 2026 07:55:24 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/8435</link> 
  <atom:link rel="self" type="application/rss+xml" title="lots of &quot;DB Error: unknown error: INSERT INTO&quot; when Horde_Cache is enabled" href="https://bugs.horde.org/ticket/8435/rss" /> 
  <description>lots of &quot;DB Error: unknown error: INSERT INTO&quot; when Horde_Cache is enabled</description> 
 
   
   
  <item> 
   <title>I have just upgraded to Horde 3.2.2 and IMP 4.1.6 and get th</title> 
   <description>I have just upgraded to Horde 3.2.2 and IMP 4.1.6 and get them working with PostgreSQL backend. Everything seems to be working just fine, but in logs, i got a lot of error messages on horde_cache tables:



[horde] DB Error: unknown error: INSERT INTO horde_cache (cache_id, cache_timestamp, cache_expiration, cache_data) VALUES (&#039;6ce9d5bdf7e6e1eee4e790cbd156b7af&#039;, 1247666680, 1247753080, FALSE) [nativecode=ERROR:  column &quot;cache_data&quot; is of type text but expression is of type boolean HINT:  You will need to rewrite or cast the expression.] [pid 32594 on line 226 of &quot;/var/www/localhost/htdocs/horde/lib/Horde/Cache/sql.php&quot;]

...

[imp] DB Error: unknown error: INSERT INTO horde_cache (cache_id, cache_timestamp, cache_expiration, cache_data) VALUES (&#039;e629f174ffe682593097290b886eaae2&#039;, 1247672866, 1247759266, FALSE) [nativecode=ERROR:  column &quot;cache_data&quot; is of type text but expression is of type boolean HINT:  You will need to rewrite or cast the expression.] [pid 3025 on line 226 of &quot;/var/www/localhost/htdocs/horde/lib/Horde/Cache/sql.php&quot;]



What other info is needed to fix this problem?</description> 
   <pubDate>Wed, 15 Jul 2009 15:56:46 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8435#t54958</link> 
  </item> 
   
  <item> 
   <title>There have been several fixes for PostgreSQL since then, ple</title> 
   <description>There have been several fixes for PostgreSQL since then, please try a more recent version first.</description> 
   <pubDate>Mon, 20 Jul 2009 15:36:55 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8435#t54993</link> 
  </item> 
   
  <item> 
   <title>If we change Horde_Cache_sql-&gt;set() method to get backtrace:</title> 
   <description>If we change Horde_Cache_sql-&gt;set() method to get backtrace:



horde/lib/Horde/Cache/sql.php



  function set($key, $data, $lifetime = null)

    {

		...

		$result = $this-&gt;_write_db-&gt;query($query, $values);

        if (is_a($result, &#039;PEAR_Error&#039;)) {

        // debug

                debug_print_backtrace();

                print &quot;&lt;br&gt;\n********$data#######&lt;br&gt;\n&quot;;

        //debug

            Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);

            return false;

        }



        return true;

    }



we&#039;ll find for these type of errors:



[imp] DB Error: unknown error: 

INSERT INTO horde_cache (cache_id, cache_timestamp, cache_expiration, cache_data) 

VALUES (&#039;8c2efd26a50e2900dc587d3922519a65&#039;, 1249954083, 1250040483, FALSE) 

[nativecode=ERROR:  column &quot;cache_data&quot; is of type text but expression is of type boolean HINT:  You will need to rewrite or cast the expression.] 

[pid 4142 on line 226 of &quot;/var/www/localhost/htdocs/horde/lib/Horde/Cache/sql.php&quot;]



backtraces like these:



#0 Horde_Cache_sql-&gt;set(perm_exists_imp:create_folders, ) called at [/var/www/horde_test/htdocs/horde/lib/Horde/Perms/datatree.php:202] 

#1 Perms_datatree-&gt;exists(imp:create_folders) called at [/var/www/horde_test/htdocs/horde/imp/lib/IMP.php:876] 

#2 IMP::hasPermission(create_folders) called at [/var/www/horde_test/htdocs/horde/imp/lib/IMP.php:588] 

#3 IMP::flistSelect(Messages to, 1, Array (), , 1, 1, , 1) called at [/var/www/horde_test/htdocs/horde/imp/mailbox.php:304] 

 ********#######

 #0 Horde_Cache_sql-&gt;set(perm_exists_imp:max_folders, ) called at [/var/www/horde_test/htdocs/horde/lib/Horde/Perms/datatree.php:202] 

#1 Perms_datatree-&gt;exists(imp:max_folders) called at [/var/www/horde_test/htdocs/horde/imp/lib/IMP.php:876] 

#2 IMP::hasPermission(max_folders) called at [/var/www/horde_test/htdocs/horde/imp/lib/IMP.php:589] 

#3 IMP::flistSelect(Messages to, 1, Array (), , 1, 1, , 1) called at [/var/www/horde_test/htdocs/horde/imp/mailbox.php:304] 

 ********#######



There are two ways to storage permissions: datatree and sql. 

If we change backend for permissions to sql, then errors will disappear.



If we compare code for &quot;Perms_[datatree/sql]-&gt;set()&quot;:



horde/lib/Horde/Perms/sql.php

------------------

    function exists($permission)

    {

        $key = &#039;perm_exists_&#039; . $permission;

        $exists = $this-&gt;_cache-&gt;get($key, $GLOBALS[&#039;conf&#039;][&#039;cache&#039;][&#039;default_lifetime&#039;]);

        if ($exists === false) {

            $this-&gt;_connect();

            $query = &#039;SELECT COUNT(*) FROM horde_perms WHERE perm_name = ?&#039;;

            $exists = $this-&gt;_db-&gt;getOne($query, array($permission));

            if (is_a($exists, &#039;PEAR_Error&#039;)) {

                return $exists;

            }



            $this-&gt;_cache-&gt;set($key, $exists);

        }



        return (bool)$exists;

    }



horde/lib/Horde/Perms/datatree.php

-------------------

   function exists($permission)

    {

        $key = &#039;perm_exists_&#039; . $permission;

        $exists = $this-&gt;_cache-&gt;get($key, $GLOBALS[&#039;conf&#039;][&#039;cache&#039;][&#039;default_lifetime&#039;]);

        if ($exists === false) {

            $exists = $this-&gt;_datatree-&gt;exists($permission);

            $this-&gt;_cache-&gt;set($key, $exists);

        }



        return (bool)$exists;

    }



It seems that reason for errors is lack of return value check in horde/lib/Horde/Perms/datatree.php

after &quot;$exists = $this-&gt;_datatree-&gt;exists($permission)&quot; call before &quot;_cache-&gt;set()&quot; like in Perms/sql.php backend.



Simple workaround.

Change backend for permission from datatree to SQL , login to the horde to create entries for create_folders, max_folders, change driver back to datatree.</description> 
   <pubDate>Tue, 11 Aug 2009 23:50:35 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8435#t55261</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in CVS for this ticket:

http://cvs.h</title> 
   <description>Changes have been made in CVS for this ticket:

http://cvs.horde.org/diff.php/framework/Perms/Perms/datatree.php?rt=horde&amp;r1=1.46&amp;r2=1.47&amp;ty=u
http://cvs.horde.org/diff.php/framework/Perms/Perms/sql.php?rt=horde&amp;r1=1.15&amp;r2=1.16&amp;ty=u
http://cvs.horde.org/diff.php/horde/docs/CHANGES?rt=horde&amp;r1=1.1248&amp;r2=1.1249&amp;ty=u</description> 
   <pubDate>Fri, 14 Aug 2009 21:42:25 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8435#t55318</link> 
  </item> 
   
  <item> 
   <title>Fixed in CVS.</title> 
   <description>Fixed in CVS.</description> 
   <pubDate>Fri, 14 Aug 2009 21:42:52 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8435#t55319</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in CVS for this ticket:

http://cvs.h</title> 
   <description>Changes have been made in CVS for this ticket:

http://cvs.horde.org/diff.php/framework/Perms/Perms/datatree.php?rt=horde&amp;r1=1.6.2.23&amp;r2=1.6.2.24&amp;ty=u
http://cvs.horde.org/diff.php/framework/Perms/Perms/sql.php?rt=horde&amp;r1=1.1.2.14&amp;r2=1.1.2.15&amp;ty=u
http://cvs.horde.org/diff.php/horde/docs/CHANGES?rt=horde&amp;r1=1.515.2.546&amp;r2=1.515.2.547&amp;ty=u</description> 
   <pubDate>Fri, 14 Aug 2009 21:45:54 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/8435#t55321</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
