summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2003-02-26 21:54:35 +0000
committerDries Buytaert <dries@buytaert.net>2003-02-26 21:54:35 +0000
commitbca66646f00d7e32c570dc22ecbaed46395aea4d (patch)
treefa2f105f2e0d2bfe4a1887c9683b65f334343a89
parentc09ab23b2e5ef1d457d7ef3a2521f6f2d28be715 (diff)
downloadbrdo-bca66646f00d7e32c570dc22ecbaed46395aea4d.tar.gz
brdo-bca66646f00d7e32c570dc22ecbaed46395aea4d.tar.bz2
- Performance improvement. Patch by Zbynek.
1) Even when string is not translated, put it in the cache and save a query for each untranslated string. 2) When there is no cache, create one.
-rw-r--r--modules/locale.module14
-rw-r--r--modules/locale/locale.module14
2 files changed, 22 insertions, 6 deletions
diff --git a/modules/locale.module b/modules/locale.module
index 4d82de8b4..d886b16fc 100644
--- a/modules/locale.module
+++ b/modules/locale.module
@@ -89,7 +89,12 @@ function locale_refresh_cache() {
foreach (array_keys($languages) as $locale) {
$result = db_query("SELECT string, %s FROM locales", $locale);
while ($data = db_fetch_object($result)) {
- $t[$data->string] = $data->$locale;
+ if (empty($data->$locale)) {
+ $t[$data->string] = $data->string;
+ }
+ else {
+ $t[$data->string] = $data->$locale;
+ }
}
cache_set("locale:$locale", serialize($t));
}
@@ -266,9 +271,11 @@ function locale($string) {
if (!isset($locale_t)) {
$cache = cache_get("locale:$locale");
- if ($cache) {
- $locale_t = unserialize($cache->data);
+ if ($cache == 0) {
+ locale_refresh_cache();
+ $cache = cache_get("locale:$locale");
}
+ $locale_t = unserialize($cache->data);
}
if ($locale_t[$string] != "") {
@@ -278,6 +285,7 @@ function locale($string) {
$result = db_query("SELECT lid, $locale FROM locales WHERE string = '%s'", $string);
if (!db_fetch_object($result)) {
db_query("INSERT INTO locales (string, location) VALUES ('%s', '%s')", $string, request_uri());
+ cache_clear_all("locale:$locale");
}
}
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 4d82de8b4..d886b16fc 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -89,7 +89,12 @@ function locale_refresh_cache() {
foreach (array_keys($languages) as $locale) {
$result = db_query("SELECT string, %s FROM locales", $locale);
while ($data = db_fetch_object($result)) {
- $t[$data->string] = $data->$locale;
+ if (empty($data->$locale)) {
+ $t[$data->string] = $data->string;
+ }
+ else {
+ $t[$data->string] = $data->$locale;
+ }
}
cache_set("locale:$locale", serialize($t));
}
@@ -266,9 +271,11 @@ function locale($string) {
if (!isset($locale_t)) {
$cache = cache_get("locale:$locale");
- if ($cache) {
- $locale_t = unserialize($cache->data);
+ if ($cache == 0) {
+ locale_refresh_cache();
+ $cache = cache_get("locale:$locale");
}
+ $locale_t = unserialize($cache->data);
}
if ($locale_t[$string] != "") {
@@ -278,6 +285,7 @@ function locale($string) {
$result = db_query("SELECT lid, $locale FROM locales WHERE string = '%s'", $string);
if (!db_fetch_object($result)) {
db_query("INSERT INTO locales (string, location) VALUES ('%s', '%s')", $string, request_uri());
+ cache_clear_all("locale:$locale");
}
}