function drupal_unpack

You are here

7 bootstrap.inc drupal_unpack($obj, $field = 'data')
4.6 bootstrap.inc drupal_unpack($obj, $field = 'data')
4.7 bootstrap.inc drupal_unpack($obj, $field = 'data')
5 bootstrap.inc drupal_unpack($obj, $field = 'data')
6 bootstrap.inc drupal_unpack($obj, $field = 'data')

Unserializes and appends elements from a serialized string.

Parameters

$obj: The object to which the elements are appended.

$field: The attribute of $obj whose value should be unserialized.

File

includes/bootstrap.inc, line 590
Functions that need to be loaded on every Drupal request.

Code

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;
}