Jelajahi Sumber

#5176 Speed performance improvements enhancements: don't use mixes for modules which don't support mixes, don't access DB to get options which aren't found in cache, since all options are already in cache

Alex Trofimov 1 tahun lalu
induk
melakukan
cf30bf5c99
1 mengubah file dengan 5 tambahan dan 14 penghapusan
  1. 5 14
      inc/classes/BxDolDb.php

+ 5 - 14
inc/classes/BxDolDb.php

@@ -780,26 +780,17 @@ class BxDolDb extends BxDolFactory implements iBxDolSingleton
         if (!$sKey)
             return false;
 
-        if ($bFromCache && $this->isParamInCache($sKey)) {
-            return self::$_aParams[$sKey];
+        if ($bFromCache) {
+            return $this->isParamInCache($sKey) ? self::$_aParams[$sKey] : false;
         } else {
-            return false;
-            /*
-            // TODO: remove DB calls from this method, since it is used in many places, 
-            //       also all settings must be in cache and there should be no need to
-            //       call DB if param is not in cache
             $sQuery = $this->prepare("SELECT `tmo`.`value` AS `value` FROM `sys_options_mixes2options` AS `tmo` INNER JOIN `sys_options_mixes` AS `tm` ON `tmo`.`mix_id`=`tm`.`id` AND `tm`.`active`='1' WHERE `tmo`.`option`=? LIMIT 1", $sKey);
-            $mixedValue = $this->getOne($sQuery);
-            if($mixedValue !== false)
-                return $mixedValue;
-
-            $sQuery = $this->prepare("SELECT `value` FROM `sys_options` WHERE `name` = ? LIMIT 1", $sKey);            
             $s = $this->getOne($sQuery);
             if($s === false) {
-                trigger_error('Unknown parameter: ' . $sKey, E_USER_ERROR);
+                $sQuery = $this->prepare("SELECT `value` FROM `sys_options` WHERE `name` = ? LIMIT 1", $sKey);            
+                $s = $this->getOne($sQuery);
             }
+            self::$_aParams[$sKey] = $s; // cache it
             return $s;
-            */
         }
     }