Commit 568b637a authored by Steve Rude's avatar Steve Rude
Browse files

Cleanup work:

  * Fixed SQL Error in memcache.db.inc
  * Added CACHE_TEMPORARY memcache caching to memcache.db.inc (full page cache and other things weren't going in)
  * Small code cleanup in memcache.db.inc
  * Changed MENU_DEFAULT_LOCAL_TASK to MENU_LOCAL_TASK in memcache_admin.module
  * Updated README.txt for memcache-session.inc

Added:
  * patches directory to hold all of the patches
  * Drupal 5.0 - 5.6 patches for core

Removed:
  * Old core serialization patch that only "kinda" applied to certain versions. Should be easier
    to know which version to use now.
parent a9e78c83
......@@ -10,14 +10,14 @@ is important.
3. Put your site into offline mode.
4. Download and install the memcache module.
5. If you have previously been running the memcache module, run update.php.
6. Apply the DRUPAL-5-cache-serialize.patch that comes with the module to your
Drupal installation.
6. Apply the DRUPAL-5-x-cache-serialize.patch from the patches folder that
comes with the module. Version specific, so use DRUPAL-5-6-cache-serialize.patch
if you are running Drupal 5.6.
7. Start at least one instance of memcached on your server.
8. Edit settings.php to configure the servers, clusters and bins that memcache
is supposed to use.
9. Edit settings.php to include either memcache.inc or memcache.db.inc.
10. Optionally, edit settings.php to include either session-memcache.inc or
sessions-memcache.db.inc.
10. Optionally, edit settings.php to include memcache-session.inc
11. Bring your site back online.
For instructions on 1 and 2 above, please see the INSTALLATION.txt file that
......
<?php
// $Id$
/**
* @file
* User session handling functions.
*/
function sess_open($save_path, $session_name) {
return TRUE;
}
function sess_close() {
return TRUE;
}
function sess_read($key) {
global $user;
// Write and Close handlers are called after destructing objects since PHP 5.0.5
// Thus destructors can use sessions but session handler can't use objects.
// So we are moving session closure before destructing objects.
register_shutdown_function('session_write_close');
// Handle the case of first time visitors and clients that don't store cookies (eg. web crawlers).
if (!isset($_COOKIE[session_name()])) {
$user = drupal_anonymous_user();
return '';
}
// Otherwise, if the session is still active, we have a record of the client's session in memcache.
$session = dmemcache_get($key, 'session');
$user = sess_user_load($session);
return $user->session;
}
function sess_write($key, $value) {
global $user;
// If the client doesn't have a session, and one isn't being created ($value), do nothing.
if (empty($_COOKIE[session_name()]) && empty($value)) {
return TRUE;
}
// Prepare the information to be saved
$session = new stdClass;
$session->sid = $key;
$session->uid = $user->uid;
$session->cache = $user->cache;
$session->hostname = $_SERVER["REMOTE_ADDR"];
$session->session = $value;
$session->timestamp = time();
if ($user->uid && $user->from_cache !== TRUE) {
dmemcache_set($key, $session, ini_get('session.gc_maxlifetime'), 'session');
dmemcache_set($user->uid, $user, ini_get('session.gc_maxlifetime'), 'users');
if ($user->uid && $user->access < time() - 300) {
db_query("UPDATE {users} SET access = %d WHERE uid = %d", time(), $user->uid);
}
}
return TRUE;
}
function sess_regenerate() {
// We code around http://bugs.php.net/bug.php?id=32802 by destroying
// the session cookie by setting expiration in the past (a negative
// value). This issue only arises in PHP versions before 4.4.0,
// regardless of the Drupal configuration.
// TODO: remove this when we require at least PHP 4.4.0
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() - 42000, '/');
}
// Store the current (anonymous) session id.
$old_session_id = session_id();
// Generate the new (authenticated) session id.
session_regenerate_id();
$key = session_id();
// Grab the user's information that is cached with the anonymous key
$info = dmemcache_get($old_session_id, 'session');
// Update it.
$info->sid = $key;
// Store it with the new key.
dmemcache_set($key, $info, ini_get('session.gc_maxlifetime'), 'session');
// Clear the old data from the cache.
dmemcache_delete($old_session_id, 'session');
}
/**
* Counts how many users have sessions. Can count either anonymous sessions, authenticated sessions, or both.
* Would be insane slow with memcached as we would need to retrieve at least the stats of all object.
* Not implemented.
*/
function sess_count($timestamp = 0, $anonymous = true) {
}
/**
* Called by PHP session handling with the PHP session ID to end a user's session.
*
* @param string $sid
* the session id
*/
function sess_destroy_sid($sid) {
dmemcache_delete($sid, 'session');
}
/**
* End a specific user's session. Not implemented.
*/
function sess_destroy_uid($uid) {
}
function sess_gc($lifetime) {
// Automatic with memcached.
// Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
// value. For example, if you want user sessions to stay in your database
// for three weeks before deleting them, you need to set gc_maxlifetime
// to '1814400'. At that value, only after a user doesn't log in after
// three weeks (1814400 seconds) will his/her session be removed.
return TRUE;
}
function sess_user_load($session) {
$user = new stdClass;
// We found the client's session record and they are an authenticated user
if ($session && $session->uid > 0) {
$user = dmemcache_get($session->uid, 'users');
if (!$user->uid && $user->uid != 0) {
$user = db_fetch_object(db_query("SELECT u.* FROM {user} u WHERE u.uid = %d", $session->uid));
$user = drupal_unpack($user);
$user->session = empty($session->session) ? '' : $session->session;
// Add roles element to $user
$user->roles = array();
$user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
$result = db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d", $user->uid);
while ($role = db_fetch_object($result)) {
$user->roles[$role->rid] = $role->name;
}
}
else if ($user->uid) {
$user->from_cache = TRUE;
$user->session = empty($session->session) ? '' : $session->session;
}
else {
// This is a rare case that we have a session cached, but no session user object cached.
// This usually only happens if you kill memcached and restart it.
$user = drupal_anonymous_user($session->session);
}
}
// We didn't find the client's record (session has expired), or they are an anonymous user.
else {
$session = isset($user->session) ? $user->session : '';
$user = drupal_anonymous_user($session);
}
return $user;
}
......@@ -133,15 +133,20 @@ function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $he
// Save to the database
db_query("
INSERT INTO {$table} (data, created, expire, headers, serialized, cid) VALUES (%b, %d, %d, '%s', %d, '%s') ON DUPLICATE KEY
UPDATE data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'",
UPDATE data = %b, created = %d, expire = %d, headers = '%s', serialized = %d",
$data, time(), $expire, $headers, $serialized, $cid,
$data, time(), $expire, $headers, $serialized, $cid);
$data, time(), $expire, $headers, $serialized);
}
// Save to memcache
if ($expire == CACHE_PERMANENT || $expire > time()) {
dmemcache_set($cid, $cache, $expire, $table);
}
else if ($expire == CACHE_TEMPORARY) {
// A compromise for CACHE_TEMPORARY: Cache for three minutes.
dmemcache_set($cid, $cache, 180, $table);
}
}
/**
......
......@@ -9,7 +9,7 @@ function memcache_admin_menu($may_cache) {
'path' => 'admin/settings/memcache',
'callback' => 'memcache_admin_stats',
'title' => t('Memcache'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'type' => MENU_LOCAL_TASK,
'access' => user_access('access memcache statistics'),
'description' => t("View the statistics for this site's memcache and generate new settings."),
);
......
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.145
diff -u -F^f -r1.145 bootstrap.inc
--- includes/bootstrap.inc 15 Jan 2007 11:52:02 -0000 1.145
+++ includes/bootstrap.inc 27 Jun 2007 07:25:26 -0000
@@ -339,14 +339,14 @@ function drupal_get_filename($type, $nam
diff -ur includes/bootstrap.inc includes/bootstrap.inc
--- includes/bootstrap.inc 2007-01-15 03:52:02.000000000 -0800
+++ includes/bootstrap.inc 2008-01-29 14:05:04.000000000 -0800
@@ -339,14 +339,14 @@
function variable_init($conf = array()) {
// NOTE: caching the variables improves performance by 20% when serving cached pages.
if ($cached = cache_get('variables', 'cache')) {
......@@ -22,14 +18,21 @@ diff -u -F^f -r1.145 bootstrap.inc
}
foreach ($conf as $name => $value) {
Index: includes/cache.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/cache.inc,v
retrieving revision 1.5
diff -u -F^f -r1.5 cache.inc
--- includes/cache.inc 10 Nov 2006 07:26:27 -0000 1.5
+++ includes/cache.inc 27 Jun 2007 07:25:26 -0000
@@ -21,12 +21,15 @@ function cache_get($key, $table = 'cache
@@ -841,7 +841,8 @@
* Drupal's bootstrap process.
*/
function _drupal_cache_init($phase) {
- require_once variable_get('cache_inc', './includes/cache.inc');
+ $cache_inc = variable_get('cache_inc', './includes/cache.inc');
+ require_once $cache_inc;
if ($phase == DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE && variable_get('page_cache_fastpath', 0)) {
if (page_cache_fastpath()) {
Only in includes: bootstrap.inc.orig
diff -ur includes/cache.inc includes/cache.inc
--- includes/cache.inc 2006-11-09 23:26:27.000000000 -0800
+++ includes/cache.inc 2008-01-29 14:05:04.000000000 -0800
@@ -21,12 +21,15 @@
variable_set('cache_flush', 0);
}
......@@ -46,7 +49,7 @@ diff -u -F^f -r1.5 cache.inc
}
// If enforcing a minimum cache lifetime, validate that the data is
// currently valid for this user before we return it by making sure the
@@ -40,6 +43,9 @@ function cache_get($key, $table = 'cache
@@ -40,6 +43,9 @@
}
else {
$cache->data = db_decode_blob($cache->data);
......@@ -56,7 +59,7 @@ diff -u -F^f -r1.5 cache.inc
}
}
return $cache;
@@ -78,8 +84,8 @@ function cache_get($key, $table = 'cache
@@ -78,8 +84,8 @@
* The table $table to store the data in. Valid core values are 'cache_filter',
* 'cache_menu', 'cache_page', or 'cache'.
* @param $data
......@@ -67,7 +70,7 @@ diff -u -F^f -r1.5 cache.inc
* One of the following values:
* - CACHE_PERMANENT: Indicates that the item should never be removed unless
* explicitly told to using cache_clear_all() with a cache ID.
@@ -91,10 +97,15 @@ function cache_get($key, $table = 'cache
@@ -91,10 +97,15 @@
* A string containing HTTP header information for cached pages.
*/
function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
......@@ -85,19 +88,15 @@ diff -u -F^f -r1.5 cache.inc
}
db_unlock_tables();
}
@@ -164,4 +175,3 @@ function cache_clear_all($cid = NULL, $t
@@ -164,4 +175,3 @@
}
}
}
-
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.146
diff -u -F^f -r1.146 menu.inc
--- includes/menu.inc 14 Jan 2007 01:37:48 -0000 1.146
+++ includes/menu.inc 27 Jun 2007 07:25:26 -0000
@@ -208,12 +208,12 @@ function menu_get_menu() {
diff -ur includes/menu.inc includes/menu.inc
--- includes/menu.inc 2007-01-13 17:37:48.000000000 -0800
+++ includes/menu.inc 2008-01-29 14:05:04.000000000 -0800
@@ -208,12 +208,12 @@
$cid = "$user->uid:$locale";
if ($cached = cache_get($cid, 'cache_menu')) {
......@@ -112,14 +111,10 @@ diff -u -F^f -r1.146 menu.inc
}
// Make sure items that cannot be cached are added.
Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.155
diff -u -F^f -r1.155 locale.module
--- modules/locale/locale.module 27 Dec 2006 13:11:59 -0000 1.155
+++ modules/locale/locale.module 27 Jun 2007 07:25:26 -0000
@@ -172,7 +172,7 @@ function locale($string) {
diff -ur modules/locale/locale.module modules/locale/locale.module
--- modules/locale/locale.module 2006-12-27 05:11:59.000000000 -0800
+++ modules/locale/locale.module 2008-01-29 14:05:04.000000000 -0800
@@ -172,7 +172,7 @@
locale_refresh_cache();
$cache = cache_get("locale:$locale", 'cache');
}
......@@ -128,7 +123,7 @@ diff -u -F^f -r1.155 locale.module
}
// We have the translation cached (if it is TRUE, then there is no
@@ -231,7 +231,7 @@ function locale_refresh_cache() {
@@ -231,7 +231,7 @@
while ($data = db_fetch_object($result)) {
$t[$data->source] = (empty($data->translation) ? TRUE : $data->translation);
}
......
diff -ur includes/bootstrap.inc includes/bootstrap.inc
--- includes/bootstrap.inc 2007-01-15 03:52:02.000000000 -0800
+++ includes/bootstrap.inc 2008-01-29 14:03:03.000000000 -0800
@@ -339,14 +339,14 @@
function variable_init($conf = array()) {
// NOTE: caching the variables improves performance by 20% when serving cached pages.
if ($cached = cache_get('variables', 'cache')) {
- $variables = unserialize($cached->data);
+ $variables = $cached->data;
}
else {
$result = db_query('SELECT * FROM {variable}');
while ($variable = db_fetch_object($result)) {
$variables[$variable->name] = unserialize($variable->value);
}
- cache_set('variables', 'cache', serialize($variables));
+ cache_set('variables', 'cache', $variables);
}
foreach ($conf as $name => $value) {
@@ -841,7 +841,8 @@
* Drupal's bootstrap process.
*/
function _drupal_cache_init($phase) {
- require_once variable_get('cache_inc', './includes/cache.inc');
+ $cache_inc = variable_get('cache_inc', './includes/cache.inc');
+ require_once $cache_inc;
if ($phase == DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE && variable_get('page_cache_fastpath', 0)) {
if (page_cache_fastpath()) {
Only in includes: bootstrap.inc.orig
diff -ur includes/cache.inc includes/cache.inc
--- includes/cache.inc 2006-11-09 23:26:27.000000000 -0800
+++ includes/cache.inc 2008-01-29 14:03:03.000000000 -0800
@@ -21,12 +21,15 @@
variable_set('cache_flush', 0);
}
- $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {%s} WHERE cid = '%s'", $table, $key));
+ $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {%s} WHERE cid = '%s'", $table, $key));
if (isset($cache->data)) {
// If the data is permanent or we're not enforcing a minimum cache lifetime
// always return the cached data.
if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
$cache->data = db_decode_blob($cache->data);
+ if ($cache->serialized) {
+ $cache->data = unserialize($cache->data);
+ }
}
// If enforcing a minimum cache lifetime, validate that the data is
// currently valid for this user before we return it by making sure the
@@ -40,6 +43,9 @@
}
else {
$cache->data = db_decode_blob($cache->data);
+ if ($cache->serialized) {
+ $cache->data = unserialize($cache->data);
+ }
}
}
return $cache;
@@ -78,8 +84,8 @@
* The table $table to store the data in. Valid core values are 'cache_filter',
* 'cache_menu', 'cache_page', or 'cache'.
* @param $data
- * The data to store in the cache. Complex data types must be serialized first.
- * @param $expire
+ * The data to store in the cache. Complex data types will be automatically serialized before insertion.
+ * Strings will be stored as plain text and not serialized. * @param $expire
* One of the following values:
* - CACHE_PERMANENT: Indicates that the item should never be removed unless
* explicitly told to using cache_clear_all() with a cache ID.
@@ -91,10 +97,15 @@
* A string containing HTTP header information for cached pages.
*/
function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
+ $serialized = 0;
+ if (is_object($data) || is_array($data)) {
+ $data = serialize($data);
+ $serialized = 1;
+ }
db_lock_table($table);
- db_query("UPDATE {%s} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $table, $data, time(), $expire, $headers, $cid);
+ db_query("UPDATE {$table} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, time(), $expire, $headers, $serialized, $cid);
if (!db_affected_rows()) {
- @db_query("INSERT INTO {%s} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $table, $cid, $data, time(), $expire, $headers);
+ @db_query("INSERT INTO {$table} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, time(), $expire, $headers, $serialized);
}
db_unlock_tables();
}
@@ -164,4 +175,3 @@
}
}
}
-
diff -ur includes/menu.inc includes/menu.inc
--- includes/menu.inc 2007-01-13 17:37:48.000000000 -0800
+++ includes/menu.inc 2008-01-29 14:03:03.000000000 -0800
@@ -208,12 +208,12 @@
$cid = "$user->uid:$locale";
if ($cached = cache_get($cid, 'cache_menu')) {
- $_menu = unserialize($cached->data);
+ $_menu = $cached->data;
}
else {
_menu_build();
// Cache the menu structure for this user, to expire after one day.
- cache_set($cid, 'cache_menu', serialize($_menu), time() + (60 * 60 * 24));
+ cache_set($cid, 'cache_menu', $_menu, time() + (60 * 60 * 24));
}
// Make sure items that cannot be cached are added.
diff -ur modules/locale/locale.module modules/locale/locale.module
--- modules/locale/locale.module 2006-12-27 05:11:59.000000000 -0800
+++ modules/locale/locale.module 2008-01-29 14:03:03.000000000 -0800
@@ -172,7 +172,7 @@
locale_refresh_cache();
$cache = cache_get("locale:$locale", 'cache');
}
- $locale_t = unserialize($cache->data);
+ $locale_t = $cache->data;
}
// We have the translation cached (if it is TRUE, then there is no
@@ -231,7 +231,7 @@
while ($data = db_fetch_object($result)) {
$t[$data->source] = (empty($data->translation) ? TRUE : $data->translation);
}
- cache_set("locale:$locale", 'cache', serialize($t));
+ cache_set("locale:$locale", 'cache', $t);
}
}
diff -ur includes/bootstrap.inc includes/bootstrap.inc
--- includes/bootstrap.inc 2007-07-26 12:16:45.000000000 -0700
+++ includes/bootstrap.inc 2008-01-29 13:56:54.000000000 -0800
@@ -382,14 +382,14 @@
function variable_init($conf = array()) {
// NOTE: caching the variables improves performance by 20% when serving cached pages.
if ($cached = cache_get('variables', 'cache')) {
- $variables = unserialize($cached->data);
+ $variables = $cached->data;
}
else {
$result = db_query('SELECT * FROM {variable}');
while ($variable = db_fetch_object($result)) {
$variables[$variable->name] = unserialize($variable->value);
}
- cache_set('variables', 'cache', serialize($variables));
+ cache_set('variables', 'cache', $variables);
}
foreach ($conf as $name => $value) {
Only in includes: bootstrap.inc.orig
diff -ur includes/cache.inc includes/cache.inc
--- includes/cache.inc 2007-06-26 20:35:48.000000000 -0700
+++ includes/cache.inc 2008-01-29 13:56:54.000000000 -0800
@@ -21,12 +21,15 @@
variable_set('cache_flush', 0);
}
- $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {". $table ."} WHERE cid = '%s'", $key));
+ $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {". $table ."} WHERE cid = '%s'", $key));
if (isset($cache->data)) {
// If the data is permanent or we're not enforcing a minimum cache lifetime
// always return the cached data.
if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
$cache->data = db_decode_blob($cache->data);
+ if ($cache->serialized) {
+ $cache->data = unserialize($cache->data);
+ }
}
// If enforcing a minimum cache lifetime, validate that the data is
// currently valid for this user before we return it by making sure the
@@ -40,6 +43,9 @@
}
else {
$cache->data = db_decode_blob($cache->data);
+ if ($cache->serialized) {
+ $cache->data = unserialize($cache->data);
+ }
}
}
return $cache;
@@ -78,8 +84,8 @@
* The table $table to store the data in. Valid core values are 'cache_filter',
* 'cache_menu', 'cache_page', or 'cache'.
* @param $data
- * The data to store in the cache. Complex data types must be serialized first.
- * @param $expire
+ * The data to store in the cache. Complex data types will be automatically serialized before insertion.
+ * Strings will be stored as plain text and not serialized. * @param $expire
* One of the following values:
* - CACHE_PERMANENT: Indicates that the item should never be removed unless
* explicitly told to using cache_clear_all() with a cache ID.
@@ -91,10 +97,15 @@
* A string containing HTTP header information for cached pages.
*/
function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
+ $serialized = 0;
+ if (is_object($data) || is_array($data)) {
+ $data = serialize($data);
+ $serialized = 1;
+ }
db_lock_table($table);
- db_query("UPDATE {". $table. "} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), $expire, $headers, $cid);
+ db_query("UPDATE {". $table. "} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, time(), $expire, $headers, $serialized, $cid);
if (!db_affected_rows()) {
- @db_query("INSERT INTO {". $table. "} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $cid, $data, time(), $expire, $headers);
+ @db_query("INSERT INTO {". $table. "} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, time(), $expire, $headers, $serialized);
}
db_unlock_tables();
}
@@ -164,4 +175,3 @@
}
}
}
-
diff -ur includes/menu.inc includes/menu.inc
--- includes/menu.inc 2007-06-16 18:50:50.000000000 -0700
+++ includes/menu.inc 2008-01-29 13:56:55.000000000 -0800
@@ -208,12 +208,12 @@
$cid = "$user->uid:$locale";
if ($cached = cache_get($cid, 'cache_menu')) {
- $_menu = unserialize($cached->data);
+ $_menu = $cached->data;
}
else {
_menu_build();
// Cache the menu structure for this user, to expire after one day.
- cache_set($cid, 'cache_menu', serialize($_menu), time() + (60 * 60 * 24));
+ cache_set($cid, 'cache_menu', $_menu, time() + (60 * 60 * 24));
}
// Make sure items that cannot be cached are added.
diff -ur modules/locale/locale.module modules/locale/locale.module
--- modules/locale/locale.module 2006-12-27 05:11:59.000000000 -0800
+++ modules/locale/locale.module 2008-01-29 13:56:55.000000000 -0800
@@ -172,7 +172,7 @@
locale_refresh_cache();
$cache = cache_get("locale:$locale", 'cache');
}
- $locale_t = unserialize($cache->data);
+ $locale_t = $cache->data;
}
// We have the translation cached (if it is TRUE, then there is no
@@ -231,7 +231,7 @@
while ($data = db_fetch_object($result)) {
$t[$data->source] = (empty($data->translation) ? TRUE : $data->translation);
}
- cache_set("locale:$locale", 'cache', serialize($t));
+ cache_set("locale:$locale", 'cache', $t);
}
}
diff -ur includes/bootstrap.inc includes/bootstrap.inc
--- includes/bootstrap.inc 2007-07-26 12:16:45.000000000 -0700
+++ includes/bootstrap.inc 2008-01-29 13:54:46.000000000 -0800
@@ -382,14 +382,14 @@
function variable_init($conf = array()) {
// NOTE: caching the variables improves performance by 20% when serving cached pages.
if ($cached = cache_get('variables', 'cache')) {
- $variables = unserialize($cached->data);
+ $variables = $cached->data;
}
else {
$result = db_query('SELECT * FROM {variable}');
while ($variable = db_fetch_object($result)) {
$variables[$variable->name] = unserialize($variable->value);
}
- cache_set('variables', 'cache', serialize($variables));
+ cache_set('variables', 'cache', $variables);
}
foreach ($conf as $name => $value) {
Only in includes: bootstrap.inc.orig
diff -ur includes/cache.inc includes/cache.inc
--- includes/cache.inc 2007-06-26 20:35:48.000000000 -0700
+++ includes/cache.inc 2008-01-29 13:54:46.000000000 -0800
@@ -21,12 +21,15 @@
variable_set('cache_flush', 0);
}
- $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {". $table ."} WHERE cid = '%s'", $key));
+ $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {". $table ."} WHERE cid = '%s'", $key));
if (isset($cache->data)) {