Remove old mysql_ cache purging code, fix type inconsistency bug in cache purging, and fix a bug in the debugger (oh, the irony)

develop
Sven Slootweg 11 years ago
parent 3fbfad8656
commit 113404d563

@ -543,24 +543,13 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass
public function PurgeCache() public function PurgeCache()
{ {
if(strpos($this->fill_query, ":Id") !== false) $parameters = array(":Id" => (string) $this->sId);
{
$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");
$query_hash = md5($this->fill_query); $query_hash = md5($this->fill_query);
$parameter_hash = md5(serialize(array(':Id' => (int) $this->sId))); $parameter_hash = md5(serialize($parameters));
$pdo_key = $query_hash . $parameter_hash; $cache_hash = $query_hash . $parameter_hash;
mc_delete($key); mc_delete($cache_hash);
mc_delete($pdo_key);
} }
public function RenderTemplate($template = "") public function RenderTemplate($template = "")

@ -221,7 +221,7 @@ function cphp_debug_display($data)
function createElements(source, key, hierarchy) function createElements(source, key, hierarchy)
{ {
var item; var item;
var id = hierarchy + "_" + key; var id = hierarchy + "_" + key.replace(/[^a-z0-9_]/gi,'');
if($.isArray(source)) if($.isArray(source))
{ {
@ -250,7 +250,7 @@ function cphp_debug_display($data)
function updateElements(source, key, hierarchy) function updateElements(source, key, hierarchy)
{ {
var item; var item;
var id = hierarchy + "_" + key; var id = hierarchy + "_" + key.replace(/[^a-z0-9_]/gi,'');
if($.isArray(source)) if($.isArray(source))
{ {

@ -38,6 +38,9 @@ class CachedPDO extends PDO
{ {
public function CachedQuery($query, $parameters = array(), $expiry = 60) 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); $query_hash = md5($query);
$parameter_hash = md5(serialize($parameters)); $parameter_hash = md5(serialize($parameters));
$cache_hash = $query_hash . $parameter_hash; $cache_hash = $query_hash . $parameter_hash;

Loading…
Cancel
Save