Changeset 21 for trunk/lib


Ignore:
Timestamp:
Nov 17, 2005 7:37:40 AM (19 years ago)
Author:
scdev
Message:

More random updates. Improved self-instantiation pattern in SessionCache? to match that of App. More little tweaks.

Location:
trunk/lib
Files:
2 edited

Legend:

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

    r20 r21  
    1313{
    1414    var $_params = array(
     15        'enabled' => true,
    1516        'soft_limit' => 204800,
    1617        'hard_limit' => 4194304,
     
    4344    function setParam($params)
    4445    {
     46        if (!isset($this) || !is_a($this, 'SessionCache')) {
     47            $this =& SessionCache::getInstance();
     48        }
     49
    4550        if (isset($params) && is_array($params)) {
    4651            // Merge new parameters with old overriding only those passed.
     
    6065    function getParam($param)
    6166    {
     67        if (!isset($this) || !is_a($this, 'SessionCache')) {
     68            $this =& SessionCache::getInstance();
     69        }
     70
    6271        if (isset($this->_params[$param])) {
    6372            return $this->_params[$param];
     
    8695    function putCache($var, $var_id, $force_it_in=false)
    8796    {
    88         $cache =& SessionCache::getInstance();
     97        if (!isset($this) || !is_a($this, 'SessionCache')) {
     98            $this =& SessionCache::getInstance();
     99        }
     100
     101        if (!$this->getParam('enabled')) {
     102            return false;
     103        }
    89104
    90105        $var_id = md5($var_id);
     
    92107        $serialized_var_len = strlen($serialized_var);
    93108       
    94         if ($serialized_var_len >= $cache->getParam('soft_limit') && !$force_it_in) {
    95             App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $cache->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
    96             return false;
    97         }
    98        
    99         if ($serialized_var_len >= $cache->getParam('hard_limit')) {
    100             App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $cache->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
     109        if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) {
     110            App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
     111            return false;
     112        }
     113       
     114        if ($serialized_var_len >= $this->getParam('hard_limit')) {
     115            App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
    101116            return false;
    102117        }
     
    107122            unset($_SESSION['_session_cache'][$var_id]);
    108123            // 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.
    109             while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $cache->getParam('soft_limit')
    110             && sizeof($_SESSION['_session_cache']) >= $cache->getParam('min_items')) {
     124            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit')
     125            && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) {
    111126                array_shift($_SESSION['_session_cache']);
    112127            }
     
    133148    function getCache($var_id)
    134149    {
     150        if (!isset($this) || !is_a($this, 'SessionCache')) {
     151            $this =& SessionCache::getInstance();
     152        }
     153
     154        if (!$this->getParam('enabled')) {
     155            return false;
     156        }
     157       
    135158        $var_id = md5($var_id);
    136159        if (isset($_SESSION['_session_cache'][$var_id])) {
     
    155178    function isCached($var_id)
    156179    {
     180        if (!isset($this) || !is_a($this, 'SessionCache')) {
     181            $this =& SessionCache::getInstance();
     182        }
     183
     184        if (!$this->getParam('enabled')) {
     185            return false;
     186        }
     187
    157188        $var_id = md5($var_id);
    158189        return isset($_SESSION['_session_cache'][$var_id]);
  • trunk/lib/TemplateGlue.inc.php

    r20 r21  
    7272        return $enum[1];
    7373    } else {
     74        App::logMsg(sprintf('No set or enum fields found.', null), LOG_DEBUG, __FILE__, __LINE__);
    7475        return false;
    7576    }
     
    8788    $values = getSetEnumFieldValues($db_table, $db_col);
    8889    if ($values === false) {
    89         ?><option value=""><?php echo _("n/a"); ?></option>
     90        ?><option value="">&nbsp;</option>
    9091        <?php
    9192        return false;
Note: See TracChangeset for help on using the changeset viewer.