From 719df1b09331472ed7c42b364f5fd3e1413147d7 Mon Sep 17 00:00:00 2001 From: marcus Date: Fri, 27 Jun 2008 09:28:56 +0000 Subject: Refs #86 - Better debug git-svn-id: https://code.elgg.org/elgg/trunk@1159 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/metastrings.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'engine/lib/metastrings.php') diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 5a91905e4..3b0fba2e7 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -26,14 +26,20 @@ $string = sanitise_string($string); $result = array_search($string, $METASTRINGS_CACHE); - if ($result!==false) + if ($result!==false) { + + if ($CONFIG->debug) + error_log("Returning id for string:$string from cache."); + return $result; + } $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where string='$string' limit 1"); if ($row) { $METASTRINGS_CACHE[$row->id] = $row->string; // Cache it + if ($CONFIG->debug) - error_log("Returning id for string {$row->string} from cache."); + error_log("Cacheing {$row->string}"); return $row->id; } @@ -53,14 +59,20 @@ $id = (int) $id; - if (isset($METASTRINGS_CACHE[$id])) - return $METASTRINGS_CACHE[$id]; + if (isset($METASTRINGS_CACHE[$id])) { + + if ($CONFIG->debug) + error_log("Returning string for id:$id from cache."); + + return $METASTRINGS_CACHE[$id]; + } $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where id='$id' limit 1"); if ($row) { $METASTRINGS_CACHE[$id] = $row->string; // Cache it + if ($CONFIG->debug) - error_log("Returning string {$row->string} from cache."); + error_log("Cacheing {$row->string}"); return $row->string; } -- cgit v1.2.3