function drupal_unpack

Same name and namespace in other branches
  1. 6.x drupal-6.x/includes/bootstrap.inc \drupal_unpack()

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.

Archivo

drupal-7.x/includes/bootstrap.inc, line 1386
Functions that need to be loaded on every Drupal request.

Código

function drupal_unpack($obj, $field = 'data') {
  if ($obj->$field && $data = unserialize($obj->$field)) {
    foreach ($data as $key => $value) {
      if (!empty($key) && !isset($obj->$key)) {
        $obj->$key = $value;
      }
    }
  }
  return $obj;
}