| 1 |
diff -ur includes/bootstrap.inc includes/bootstrap.inc
|
| 2 |
--- includes/bootstrap.inc 2007-01-15 03:52:02.000000000 -0800
|
| 3 |
+++ includes/bootstrap.inc 2008-01-29 14:03:03.000000000 -0800
|
| 4 |
@@ -339,14 +339,14 @@
|
| 5 |
function variable_init($conf = array()) {
|
| 6 |
// NOTE: caching the variables improves performance by 20% when serving cached pages.
|
| 7 |
if ($cached = cache_get('variables', 'cache')) {
|
| 8 |
- $variables = unserialize($cached->data);
|
| 9 |
+ $variables = $cached->data;
|
| 10 |
}
|
| 11 |
else {
|
| 12 |
$result = db_query('SELECT * FROM {variable}');
|
| 13 |
while ($variable = db_fetch_object($result)) {
|
| 14 |
$variables[$variable->name] = unserialize($variable->value);
|
| 15 |
}
|
| 16 |
- cache_set('variables', 'cache', serialize($variables));
|
| 17 |
+ cache_set('variables', 'cache', $variables);
|
| 18 |
}
|
| 19 |
|
| 20 |
foreach ($conf as $name => $value) {
|
| 21 |
@@ -841,7 +841,8 @@
|
| 22 |
* Drupal's bootstrap process.
|
| 23 |
*/
|
| 24 |
function _drupal_cache_init($phase) {
|
| 25 |
- require_once variable_get('cache_inc', './includes/cache.inc');
|
| 26 |
+ $cache_inc = variable_get('cache_inc', './includes/cache.inc');
|
| 27 |
+ require_once $cache_inc;
|
| 28 |
|
| 29 |
if ($phase == DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE && variable_get('page_cache_fastpath', 0)) {
|
| 30 |
if (page_cache_fastpath()) {
|
| 31 |
Only in includes: bootstrap.inc.orig
|
| 32 |
diff -ur includes/cache.inc includes/cache.inc
|
| 33 |
--- includes/cache.inc 2006-11-09 23:26:27.000000000 -0800
|
| 34 |
+++ includes/cache.inc 2008-01-29 14:03:03.000000000 -0800
|
| 35 |
@@ -21,12 +21,15 @@
|
| 36 |
variable_set('cache_flush', 0);
|
| 37 |
}
|
| 38 |
|
| 39 |
- $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {%s} WHERE cid = '%s'", $table, $key));
|
| 40 |
+ $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {%s} WHERE cid = '%s'", $table, $key));
|
| 41 |
if (isset($cache->data)) {
|
| 42 |
// If the data is permanent or we're not enforcing a minimum cache lifetime
|
| 43 |
// always return the cached data.
|
| 44 |
if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
|
| 45 |
$cache->data = db_decode_blob($cache->data);
|
| 46 |
+ if ($cache->serialized) {
|
| 47 |
+ $cache->data = unserialize($cache->data);
|
| 48 |
+ }
|
| 49 |
}
|
| 50 |
// If enforcing a minimum cache lifetime, validate that the data is
|
| 51 |
// currently valid for this user before we return it by making sure the
|
| 52 |
@@ -40,6 +43,9 @@
|
| 53 |
}
|
| 54 |
else {
|
| 55 |
$cache->data = db_decode_blob($cache->data);
|
| 56 |
+ if ($cache->serialized) {
|
| 57 |
+ $cache->data = unserialize($cache->data);
|
| 58 |
+ }
|
| 59 |
}
|
| 60 |
}
|
| 61 |
return $cache;
|
| 62 |
@@ -78,8 +84,8 @@
|
| 63 |
* The table $table to store the data in. Valid core values are 'cache_filter',
|
| 64 |
* 'cache_menu', 'cache_page', or 'cache'.
|
| 65 |
* @param $data
|
| 66 |
- * The data to store in the cache. Complex data types must be serialized first.
|
| 67 |
- * @param $expire
|
| 68 |
+ * The data to store in the cache. Complex data types will be automatically serialized before insertion.
|
| 69 |
+ * Strings will be stored as plain text and not serialized. * @param $expire
|
| 70 |
* One of the following values:
|
| 71 |
* - CACHE_PERMANENT: Indicates that the item should never be removed unless
|
| 72 |
* explicitly told to using cache_clear_all() with a cache ID.
|
| 73 |
@@ -91,10 +97,15 @@
|
| 74 |
* A string containing HTTP header information for cached pages.
|
| 75 |
*/
|
| 76 |
function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
|
| 77 |
+ $serialized = 0;
|
| 78 |
+ if (is_object($data) || is_array($data)) {
|
| 79 |
+ $data = serialize($data);
|
| 80 |
+ $serialized = 1;
|
| 81 |
+ }
|
| 82 |
db_lock_table($table);
|
| 83 |
- db_query("UPDATE {%s} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $table, $data, time(), $expire, $headers, $cid);
|
| 84 |
+ db_query("UPDATE {$table} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, time(), $expire, $headers, $serialized, $cid);
|
| 85 |
if (!db_affected_rows()) {
|
| 86 |
- @db_query("INSERT INTO {%s} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $table, $cid, $data, time(), $expire, $headers);
|
| 87 |
+ @db_query("INSERT INTO {$table} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, time(), $expire, $headers, $serialized);
|
| 88 |
}
|
| 89 |
db_unlock_tables();
|
| 90 |
}
|
| 91 |
@@ -164,4 +175,3 @@
|
| 92 |
}
|
| 93 |
}
|
| 94 |
}
|
| 95 |
-
|
| 96 |
diff -ur includes/menu.inc includes/menu.inc
|
| 97 |
--- includes/menu.inc 2007-01-13 17:37:48.000000000 -0800
|
| 98 |
+++ includes/menu.inc 2008-01-29 14:03:03.000000000 -0800
|
| 99 |
@@ -208,12 +208,12 @@
|
| 100 |
|
| 101 |
$cid = "$user->uid:$locale";
|
| 102 |
if ($cached = cache_get($cid, 'cache_menu')) {
|
| 103 |
- $_menu = unserialize($cached->data);
|
| 104 |
+ $_menu = $cached->data;
|
| 105 |
}
|
| 106 |
else {
|
| 107 |
_menu_build();
|
| 108 |
// Cache the menu structure for this user, to expire after one day.
|
| 109 |
- cache_set($cid, 'cache_menu', serialize($_menu), time() + (60 * 60 * 24));
|
| 110 |
+ cache_set($cid, 'cache_menu', $_menu, time() + (60 * 60 * 24));
|
| 111 |
}
|
| 112 |
|
| 113 |
// Make sure items that cannot be cached are added.
|
| 114 |
diff -ur modules/locale/locale.module modules/locale/locale.module
|
| 115 |
--- modules/locale/locale.module 2006-12-27 05:11:59.000000000 -0800
|
| 116 |
+++ modules/locale/locale.module 2008-01-29 14:03:03.000000000 -0800
|
| 117 |
@@ -172,7 +172,7 @@
|
| 118 |
locale_refresh_cache();
|
| 119 |
$cache = cache_get("locale:$locale", 'cache');
|
| 120 |
}
|
| 121 |
- $locale_t = unserialize($cache->data);
|
| 122 |
+ $locale_t = $cache->data;
|
| 123 |
}
|
| 124 |
|
| 125 |
// We have the translation cached (if it is TRUE, then there is no
|
| 126 |
@@ -231,7 +231,7 @@
|
| 127 |
while ($data = db_fetch_object($result)) {
|
| 128 |
$t[$data->source] = (empty($data->translation) ? TRUE : $data->translation);
|
| 129 |
}
|
| 130 |
- cache_set("locale:$locale", 'cache', serialize($t));
|
| 131 |
+ cache_set("locale:$locale", 'cache', $t);
|
| 132 |
}
|
| 133 |
}
|
| 134 |
|