[Tickets #8435] Re: lots of "DB Error: unknown error: INSERT INTO" when Horde_Cache is enabled

bugs at horde.org bugs at horde.org
Tue Aug 11 23:50:36 UTC 2009


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/8435
------------------------------------------------------------------------------
  Ticket             | 8435
  Updated By         | tek at dgap.mipt.ru
  Summary            | lots of "DB Error: unknown error: INSERT INTO" when
                     | Horde_Cache is enabled
  Queue              | Horde Base
  Version            | 3.2.2
  Type               | Bug
  State              | No Feedback
  Priority           | 1. Low
  Milestone          |
  Patch              |
  Owners             |
------------------------------------------------------------------------------


tek at dgap.mipt.ru (2009-08-11 19:50) wrote:

If we change Horde_Cache_sql->set() method to get backtrace:

horde/lib/Horde/Cache/sql.php

   function set($key, $data, $lifetime = null)
     {
		...
		$result = $this->_write_db->query($query, $values);
         if (is_a($result, 'PEAR_Error')) {
         // debug
                 debug_print_backtrace();
                 print "<br>\n********$data#######<br>\n";
         //debug
             Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
             return false;
         }

         return true;
     }

we'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 ('8c2efd26a50e2900dc587d3922519a65', 1249954083, 1250040483, FALSE)
[nativecode=ERROR:  column "cache_data" 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  
"/var/www/localhost/htdocs/horde/lib/Horde/Cache/sql.php"]

backtraces like these:

#0 Horde_Cache_sql->set(perm_exists_imp:create_folders, ) called at  
[/var/www/horde_test/htdocs/horde/lib/Horde/Perms/datatree.php:202]
#1 Perms_datatree->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->set(perm_exists_imp:max_folders, ) called at  
[/var/www/horde_test/htdocs/horde/lib/Horde/Perms/datatree.php:202]
#1 Perms_datatree->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 "Perms_[datatree/sql]->set()":

horde/lib/Horde/Perms/sql.php
------------------
     function exists($permission)
     {
         $key = 'perm_exists_' . $permission;
         $exists = $this->_cache->get($key,  
$GLOBALS['conf']['cache']['default_lifetime']);
         if ($exists === false) {
             $this->_connect();
             $query = 'SELECT COUNT(*) FROM horde_perms WHERE perm_name = ?';
             $exists = $this->_db->getOne($query, array($permission));
             if (is_a($exists, 'PEAR_Error')) {
                 return $exists;
             }

             $this->_cache->set($key, $exists);
         }

         return (bool)$exists;
     }

horde/lib/Horde/Perms/datatree.php
-------------------
    function exists($permission)
     {
         $key = 'perm_exists_' . $permission;
         $exists = $this->_cache->get($key,  
$GLOBALS['conf']['cache']['default_lifetime']);
         if ($exists === false) {
             $exists = $this->_datatree->exists($permission);
             $this->_cache->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 "$exists = $this->_datatree->exists($permission)" call before  
"_cache->set()" 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.






More information about the bugs mailing list