summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/bootstrap.inc16
-rw-r--r--includes/session.inc8
2 files changed, 17 insertions, 7 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 8f0fa9ec6..9f59b7237 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -161,6 +161,22 @@ function bootstrap_hooks() {
return array('init', 'exit');
}
+/*
+** Unserializes and appends elements from a serialized string
+** $obj is the object to which we shall append
+** $field is the element whose value is a serialized string
+*/
+function drupal_unpack($obj, $field = 'data') {
+ if ($obj->$field && $data = unserialize($obj->$field)) {
+ foreach ($data as $key => $value) {
+ if (!isset($obj->$key)) {
+ $obj->$key = $value;
+ }
+ }
+ }
+ return $obj;
+}
+
function referer_uri() {
if (isset($_SERVER["HTTP_REFERER"])) {
return check_url($_SERVER["HTTP_REFERER"]);
diff --git a/includes/session.inc b/includes/session.inc
index f2eb64975..71dc64806 100644
--- a/includes/session.inc
+++ b/includes/session.inc
@@ -25,13 +25,7 @@ function sess_read($key) {
}
$user = db_fetch_object($result);
- if ($user->data && $data = unserialize($user->data)) {
- foreach ($data as $key => $value) {
- if (!isset($user->$key)) {
- $user->$key = $value;
- }
- }
- }
+ $user = drupal_unpack($user);
return !empty($user->session) ? $user->session : '';
}