From dbfcd7d13716a5ad10ad454ca2e22339008c1fd2 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 25 Apr 2007 21:34:32 +0000 Subject: - Patch #137415 by slantview: simplified the cache API/usages, and made it a tad smarter. Makes it easier to program for, and easier to replace. Will need to be documented. --- modules/locale/locale.module | 4 ++-- modules/system/system.install | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 5bd955824..a419af94a 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -245,7 +245,7 @@ function locale($string) { locale_refresh_cache(); $cache = cache_get('locale:'. $language->language, 'cache'); } - $locale_t = unserialize($cache->data); + $locale_t = $cache->data; } // We have the translation cached (if it is TRUE, then there is no @@ -305,7 +305,7 @@ function locale_refresh_cache() { while ($data = db_fetch_object($result)) { $t[$data->source] = (empty($data->translation) ? TRUE : $data->translation); } - cache_set('locale:'. $language->language, serialize($t)); + cache_set('locale:'. $language->language, $t); } } diff --git a/modules/system/system.install b/modules/system/system.install index b5f93887d..f409de7fa 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -219,6 +219,7 @@ function system_install() { expire int NOT NULL default '0', created int NOT NULL default '0', headers text, + serialized int(1) NOT NULL default '0', PRIMARY KEY (cid), INDEX expire (expire) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); @@ -228,6 +229,7 @@ function system_install() { expire int NOT NULL default '0', created int NOT NULL default '0', headers text, + serialized int(1) NOT NULL default '0', PRIMARY KEY (cid), INDEX expire (expire) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); @@ -237,6 +239,7 @@ function system_install() { expire int NOT NULL default '0', created int NOT NULL default '0', headers text, + serialized int(1) NOT NULL default '0', PRIMARY KEY (cid), INDEX expire (expire) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); @@ -692,6 +695,7 @@ function system_install() { expire int NOT NULL default '0', created int NOT NULL default '0', headers text, + serialized int(1) NOT NULL default '0', PRIMARY KEY (cid) )"); db_query("CREATE TABLE {cache_filter} ( @@ -700,6 +704,7 @@ function system_install() { expire int NOT NULL default '0', created int NOT NULL default '0', headers text, + serialized int(1) NOT NULL default '0', PRIMARY KEY (cid) )"); db_query("CREATE TABLE {cache_page} ( @@ -708,6 +713,7 @@ function system_install() { expire int NOT NULL default '0', created int NOT NULL default '0', headers text, + serialized int(1) NOT NULL default '0', PRIMARY KEY (cid) )"); db_query("CREATE INDEX {cache}_expire_idx ON {cache} (expire)"); @@ -3816,6 +3822,30 @@ function system_update_6011() { return $ret; } +/** + * Add serialized field to cache tables + */ +function system_update_6012() { + $ret = array(); + + switch ($GLOBALS['db_type']) { + case 'pgsql': + db_add_column($ret, 'cache', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE)); + db_add_column($ret, 'cache_filter', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE)); + db_add_column($ret, 'cache_page', 'serialized', 'int(1)', array('default' => "'0'", 'not null' => TRUE)); + break; + case 'mysql': + case 'mysqli': + $ret[] = update_sql("ALTER TABLE {cache} ADD serialized int(1) NOT NULL default '0'"); + $ret[] = update_sql("ALTER TABLE {cache_filter} ADD serialized int(1) NOT NULL default '0'"); + $ret[] = update_sql("ALTER TABLE {cache_page} ADD serialized int(1) NOT NULL default '0'"); + break; + + } + + return $ret; +} + /** * @} End of "defgroup updates-5.x-to-6.x" * The next series of updates should start at 7000. -- cgit v1.2.3