Changeset 218


Ignore:
Timestamp:
Dec 17, 2006 10:27:56 AM (17 years ago)
Author:
quinn
Message:

Q - ALC class: added a cache->delete() when modifying grants.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/ACL.inc.php

    r209 r218  
    508508        $axo = is_null($axo) ? 'root' : $axo;
    509509       
     510        // Flush old cached values.
     511        $cache_hash = $aro . '|' . $aco . '|' . $axo;
     512        $this->cache->delete($cache_hash);
     513
    510514        // Ensure values exist.
    511515        $qid = $db->query("SELECT aro_tbl.aro_id FROM aro_tbl WHERE aro_tbl.name = '" . $db->escapeString($aro) . "'");
     
    579583        $where[] = is_null($aco) ? "aco_tbl.name IS NOT NULL" : "aco_tbl.name = '" . $db->escapeString($aco) . "' ";
    580584        $where[] = is_null($axo) ? "axo_tbl.name IS NOT NULL" : "axo_tbl.name = '" . $db->escapeString($axo) . "' ";
     585
     586        // If any access objects are null, assume using root values.
     587        // However if they're empty we don't want to escalate the grant command to root!
     588        $aro = is_null($aro) ? 'root' : $aro;
     589        $aco = is_null($aco) ? 'root' : $aco;
     590        $axo = is_null($axo) ? 'root' : $axo;
     591       
     592        // Flush old cached values.
     593        $cache_hash = $aro . '|' . $aco . '|' . $axo;
     594        $this->cache->delete($cache_hash);
    581595
    582596        $final_where = join(' AND ', $where);
  • trunk/lib/Cache.inc.php

    r201 r218  
    186186        }
    187187
    188         if (isset($_SESSION['_cache'][$this->_ns][$key])) {
     188        if (array_key_exists($key, $_SESSION['_cache'][$this->_ns])) {
    189189            $app->logMsg(sprintf('Retreiving %s from cache.', $key), LOG_DEBUG, __FILE__, __LINE__);
    190190            // Move the accessed cached datum to the top of the stack. Maybe somebody knows a better way to do this?
     
    204204     *
    205205     * @param string $key  The key of the object to check.
    206      * @return bool           The return from isset().
     206     * @return bool         True if a value exists for the given key.
    207207     */
    208208    function exists($key)
     
    219219     *
    220220     * @param string $key  The key of the object to check.
    221      * @return bool           The return from isset().
     221     * @return bool         True if the value existed before being unset.
    222222     */
    223223    function delete($key)
    224224    {
    225         unset($_SESSION['_cache'][$this->_ns][$key]);
     225        if (array_key_exists($key, $_SESSION['_cache'][$this->_ns])) {
     226            unset($_SESSION['_cache'][$this->_ns][$key]);
     227            return true;
     228        } else {
     229            return false;
     230        }
    226231    }
    227232   
Note: See TracChangeset for help on using the changeset viewer.