From ea1ad666f79917a131f38038cfc3dee072ef3d84 Mon Sep 17 00:00:00 2001 From: rGaillard Date: Thu, 20 Sep 2012 14:04:15 +0000 Subject: [PATCH] // small fix git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17441 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/cache/Cache.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/classes/cache/Cache.php b/classes/cache/Cache.php index aa5784950..e6eaab318 100755 --- a/classes/cache/Cache.php +++ b/classes/cache/Cache.php @@ -248,13 +248,21 @@ abstract class CacheCore $this->set($key, $result); // Get all table from the query and save them in cache - if (preg_match_all('/('._DB_PREFIX_.'[a-z_-]*)`?.*/i', $query, $res)) - foreach ($res[1] as $table) + if ($tables = $this->getTables($query)) + foreach ($tables as $table) if (!isset($this->sql_tables_cached[$table][$key])) $this->sql_tables_cached[$table][$key] = true; $this->set(self::SQL_TABLES_NAME, $this->sql_tables_cached); } + protected function getTables($string) + { + if (preg_match_all('/(?:from|join|update|into)\s+`?('._DB_PREFIX_.'[a-z_-]+)`?(?:,\s{0,}`?('._DB_PREFIX_.'[a-z_-]+)`?)?\s.*/Umsi', $string, $res)) + return array_merge($res[1], $res[2]); + else + return false; + } + /** * Delete a query from cache * @@ -269,9 +277,7 @@ abstract class CacheCore $this->sql_tables_cached = array(); } - if (preg_match_all('/(?:from|join|update|into)\s+`?('._DB_PREFIX_.'[a-z_-]+)`?(?:,\s{0,}`?('._DB_PREFIX_.'[a-z_-]+)`?)?\s.*/Umsi', $query, $res)) - { - $tables = array_merge($res[1], $res[2]); + if ($tables = $this->getTables($query)) foreach ($tables as $table) if (isset($this->sql_tables_cached[$table])) { @@ -282,7 +288,6 @@ abstract class CacheCore } unset($this->sql_tables_cached[$table]); } - } $this->set(self::SQL_TABLES_NAME, $this->sql_tables_cached); }