<?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>Incorrect return type from cache miss</title> 
  <pubDate>Fri, 10 Apr 2026 19:28:26 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/6060</link> 
  <atom:link rel="self" type="application/rss+xml" title="Incorrect return type from cache miss" href="https://bugs.horde.org/ticket/6060/rss" /> 
  <description>Incorrect return type from cache miss</description> 
 
   
   
  <item> 
   <title>I have Horde FW_3 from CVS as of about 2 hours ago.  My inst</title> 
   <description>I have Horde FW_3 from CVS as of about 2 hours ago.  My installation is configured to use the MySQL cache backend.  While calling $perms-&gt;exists() I see that a cache miss results in an erroneous $perms result.  Fortunately it is a &quot;fail-closed&quot; so no extra permissions are granted, but the unsuspecting user will not see the application to which he has been granted.



From framework/Perms/Perms/datatree.php line 139:

        $perm = $this-&gt;_cache-&gt;get(&#039;perm_&#039; . $name, $GLOBALS[&#039;conf&#039;][&#039;cache&#039;][&#039;default_lifetime&#039;]);

        if ($perm === false) {

$this-&gt;_cache-&gt;set(&#039;perm_&#039; . $name, serialize($perm), $GLOBALS[&#039;conf&#039;][&#039;cache&#039;][&#039;default_lifetime&#039;]);

            $permsCache[$name] = $perm;

        }



This code expects a cache miss to return a false.  Inspection of the code seems to take some care to ensure this happens (for instance on a DB error).  However the return type for DB::common::getOne() is NULL if the row does not exist.  This causes entries which have not yet been cached to return a type of NULL.  From line 150 of framework/Cache/Cache/sql.php:



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

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

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

            return false;

        } else {

            if ($this-&gt;_mc) {

                $this-&gt;_mc-&gt;set($key, $result);

            }

            return $result;

        }



I *think* the correct action here would be to check for a return type of NULL from getOne() and then return false, indicating a cache miss.  However, I&#039;m not very coherent on the bigger picture for the Cache system yet, so I&#039;ll leave it for discussion here.  Did I miss something?



Practical example:  In my case I have a module called &quot;site&quot; which has granted &quot;show/read&quot; perms to Guests.  When a guest goes into that app they are prompted with a login screen.  Inserting debug statements into the code shows that while I have indeed defined a &quot;site&quot; permission, it is never checked directly because the Perms/datatree code receives a NULL from the Cache driver.</description> 
   <pubDate>Wed, 02 Jan 2008 03:43:56 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/6060#t40616</link> 
  </item> 
   
  <item> 
   <title>Yup, needed an is_null check. Thanks.</title> 
   <description>Yup, needed an is_null check. Thanks.</description> 
   <pubDate>Wed, 02 Jan 2008 19:38:32 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/6060#t40626</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
