]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Don't hit DB on elgg_get_config after putting all configuration into local object
authorPaweł Sroka <srokap@gmail.com>
Sun, 4 Nov 2012 03:39:50 +0000 (04:39 +0100)
committerSteve Clay <steve@mrclay.org>
Wed, 28 Nov 2012 04:15:56 +0000 (23:15 -0500)
engine/lib/configuration.php

index 305aa00b6a2172662381128e748e5fe5abe65d6b..540312481293f8424050125cf3ab194b627ba671 100644 (file)
@@ -95,11 +95,14 @@ function elgg_get_config($name, $site_guid = 0) {
                // installation wide setting
                $value = datalist_get($name);
        } else {
-               // site specific setting
-               if ($site_guid == 0) {
-                       $site_guid = (int) $CONFIG->site_id;
+               // hit DB only if we're not sure if value exists or not
+               if (!isset($CONFIG->site_config_loaded)) {
+                       // site specific setting
+                       if ($site_guid == 0) {
+                               $site_guid = (int) $CONFIG->site_id;
+                       }
+                       $value = get_config($name, $site_guid);
                }
-               $value = get_config($name, $site_guid);
        }
 
        if ($value !== false) {
@@ -558,6 +561,8 @@ function _elgg_load_site_config() {
        $CONFIG->url = $CONFIG->wwwroot;
 
        get_all_config();
+       // gives hint to elgg_get_config function how to approach missing values
+       $CONFIG->site_config_loaded = true;
 }
 
 /**