Ignore:
Timestamp:
Jun 9, 2006 9:25:54 PM (18 years ago)
Author:
scdev
Message:

Q - added tags/2.0.2 as the first php5 compatible version of the 2.0 branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/lib/SessionCache.inc.php

    r53 r157  
    4444    function setParam($params)
    4545    {
    46         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    47             $this =& SessionCache::getInstance();
    48         }
     46        $_this =& SessionCache::getInstance();
    4947
    5048        if (isset($params) && is_array($params)) {
    5149            // Merge new parameters with old overriding only those passed.
    52             $this->_params = array_merge($this->_params, $params);
     50            $_this->_params = array_merge($_this->_params, $params);
    5351        } else {
    5452            App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     
    6563    function getParam($param)
    6664    {
    67         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    68             $this =& SessionCache::getInstance();
    69         }
    70 
    71         if (isset($this->_params[$param])) {
    72             return $this->_params[$param];
     65        $_this =& SessionCache::getInstance();
     66
     67        if (isset($_this->_params[$param])) {
     68            return $_this->_params[$param];
    7369        } else {
    7470            App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     
    9591    function putCache($var, $var_id, $force_it_in=false)
    9692    {
    97         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    98             $this =& SessionCache::getInstance();
    99         }
    100 
    101         if (!$this->getParam('enabled')) {
     93        $_this =& SessionCache::getInstance();
     94
     95        if (!$_this->getParam('enabled')) {
    10296            App::logMsg(sprintf('SessionCache not enabled, not saving data.', null), LOG_DEBUG, __FILE__, __LINE__);
    10397            return false;
     
    108102        $serialized_var_len = strlen($serialized_var);
    109103
    110         if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) {
    111             App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
    112             return false;
    113         }
    114 
    115         if ($serialized_var_len >= $this->getParam('hard_limit')) {
    116             App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
     104        if ($serialized_var_len >= $_this->getParam('soft_limit') && !$force_it_in) {
     105            App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $_this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
     106            return false;
     107        }
     108
     109        if ($serialized_var_len >= $_this->getParam('hard_limit')) {
     110            App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $_this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
    117111            return false;
    118112        }
     
    123117            unset($_SESSION['_session_cache'][$var_id]);
    124118            // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least.
    125             while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit')
    126             && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) {
     119            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $_this->getParam('soft_limit')
     120            && sizeof($_SESSION['_session_cache']) >= $_this->getParam('min_items')) {
    127121                array_shift($_SESSION['_session_cache']);
    128122            }
     
    149143    function getCache($var_id)
    150144    {
    151         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    152             $this =& SessionCache::getInstance();
    153         }
    154 
    155         if (!$this->getParam('enabled')) {
     145        $_this =& SessionCache::getInstance();
     146
     147        if (!$_this->getParam('enabled')) {
    156148            return false;
    157149        }
     
    179171    function isCached($var_id)
    180172    {
    181         if (!isset($this) || !is_a($this, 'SessionCache') && !is_subclass_of($this, 'SessionCache')) {
    182             $this =& SessionCache::getInstance();
    183         }
    184 
    185         if (!$this->getParam('enabled')) {
     173        $_this =& SessionCache::getInstance();
     174
     175        if (!$_this->getParam('enabled')) {
    186176            return false;
    187177        }
Note: See TracChangeset for help on using the changeset viewer.