diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-27 15:46:37 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-27 15:46:37 +0000 |
commit | d344018e1960fbc3805c0afed2eb8786dbb06ba6 (patch) | |
tree | 20c2e67e14596cb1c737fb47729077994f3c5b5e /engine/lib | |
parent | 437e4e00ec2bb9ff209bed2a772aa52f5b92f97f (diff) | |
download | elgg-d344018e1960fbc3805c0afed2eb8786dbb06ba6.tar.gz elgg-d344018e1960fbc3805c0afed2eb8786dbb06ba6.tar.bz2 |
Metastrings now keeps a record of strings it knows aren't present and so removes the need to futher look for them. Refs #101
git-svn-id: https://code.elgg.org/elgg/trunk@1189 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/metastrings.php | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index cf484b2d4..ef19df9e5 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -13,6 +13,8 @@ /** Cache metastrings for a page */ $METASTRINGS_CACHE = array(); + + $METASTRINGS_DEADNAME_CACHE = array(); /** * Return the meta string id for a given tag, or false. @@ -22,7 +24,7 @@ */ function get_metastring_id($string) { - global $CONFIG, $METASTRINGS_CACHE; + global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; $string = sanitise_string($string); $result = array_search($string, $METASTRINGS_CACHE); @@ -34,6 +36,10 @@ return $result; } + // See if we have previously looked for this and found nothing + if (in_array($string, $METASTRINGS_DEADNAME_CACHE)) + return false; + $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where string='$string' limit 1"); if ($row) { $METASTRINGS_CACHE[$row->id] = $row->string; // Cache it @@ -43,6 +49,8 @@ return $row->id; } + else + $METASTRINGS_DEADNAME_CACHE[$string] = $string; return false; }
@@ -90,7 +98,7 @@ */ function add_metastring($string) { - global $CONFIG, $METASTRINGS_CACHE; + global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE; $sanstring = sanitise_string($string); @@ -98,8 +106,10 @@ if ($id) return $id; $result = insert_data("INSERT into {$CONFIG->dbprefix}metastrings (string) values ('$sanstring')"); - if ($result) + if ($result) { $METASTRINGS_CACHE[$result] = $string; + if (isset($METASTRINGS_DEADNAME_CACHE[$string])) unset($METASTRINGS_DEADNAME_CACHE[$string]); + } return $result; } |