diff --git a/class.databaserecord.php b/class.databaserecord.php index 35db37e..64a4301 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -543,24 +543,13 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass public function PurgeCache() { - if(strpos($this->fill_query, ":Id") !== false) - { - $fill_query = str_replace(":Id", "'%d'", $this->fill_query); - } - else - { - $fill_query = $this->fill_query; - } - - $query = sprintf($fill_query, $this->sId); - $key = md5($query) . md5($query . "x"); + $parameters = array(":Id" => (string) $this->sId); $query_hash = md5($this->fill_query); - $parameter_hash = md5(serialize(array(':Id' => (int) $this->sId))); - $pdo_key = $query_hash . $parameter_hash; + $parameter_hash = md5(serialize($parameters)); + $cache_hash = $query_hash . $parameter_hash; - mc_delete($key); - mc_delete($pdo_key); + mc_delete($cache_hash); } public function RenderTemplate($template = "") diff --git a/include.debug.php b/include.debug.php index 285da59..8a19a02 100644 --- a/include.debug.php +++ b/include.debug.php @@ -221,7 +221,7 @@ function cphp_debug_display($data) function createElements(source, key, hierarchy) { var item; - var id = hierarchy + "_" + key; + var id = hierarchy + "_" + key.replace(/[^a-z0-9_]/gi,''); if($.isArray(source)) { @@ -250,7 +250,7 @@ function cphp_debug_display($data) function updateElements(source, key, hierarchy) { var item; - var id = hierarchy + "_" + key; + var id = hierarchy + "_" + key.replace(/[^a-z0-9_]/gi,''); if($.isArray(source)) { diff --git a/include.mysql.php b/include.mysql.php index e725578..d863b9d 100644 --- a/include.mysql.php +++ b/include.mysql.php @@ -38,6 +38,9 @@ class CachedPDO extends PDO { public function CachedQuery($query, $parameters = array(), $expiry = 60) { + /* TODO: Do type guessing before checking cache, so as to avoid + * different parameter hashes depending on input type for + * numbers. */ $query_hash = md5($query); $parameter_hash = md5(serialize($parameters)); $cache_hash = $query_hash . $parameter_hash;