aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-11-27 23:17:41 -0500
committerSteve Clay <steve@mrclay.org>2012-11-27 23:17:41 -0500
commit4e85a7e00517fefa817b643827e7faae9e289992 (patch)
tree3da55a8d68d103611ad8346ba38d5f5ef2fb69ca /engine
parent85dd37123cdd25b8f70cba913383ceba615a785e (diff)
parent8e0355da502d3e61e6c5ef66f34831cfbad6506e (diff)
downloadelgg-4e85a7e00517fefa817b643827e7faae9e289992.tar.gz
elgg-4e85a7e00517fefa817b643827e7faae9e289992.tar.bz2
Merge branch 'optimize-elgg_get_config' into 1.8
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/configuration.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php
index 305aa00b6..b10e51130 100644
--- a/engine/lib/configuration.php
+++ b/engine/lib/configuration.php
@@ -91,23 +91,29 @@ function elgg_get_config($name, $site_guid = 0) {
return $CONFIG->$name;
}
- if ($site_guid === NULL) {
+ if ($site_guid === null) {
// 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);
+ } else {
+ $value = null;
}
- $value = get_config($name, $site_guid);
}
- if ($value !== false) {
- $CONFIG->$name = $value;
- return $value;
+ // @todo document why we don't cache false
+ if ($value === false) {
+ return null;
}
- return null;
+ $CONFIG->$name = $value;
+ return $value;
}
/**
@@ -558,6 +564,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;
}
/**