Drupal 7 Drupal节点\u save未保存字段

Drupal 7 Drupal节点\u save未保存字段,drupal-7,Drupal 7,我刚刚偶然发现了非常奇怪的行为。在我的代码中,我用一些字段保存新节点。我必须说,这种方法过去运作得非常好。然而,现在它只是停止工作。我使用devel模块打印出对象和变量的内容,这是我的代码: 第一个dsm函数显示我创建的节点对象以及它应该显示的节点对象。第二个dsm函数显示完全正确的节点对象,并填充nid、字段内容等。。。然而,尽管{node}表中有新记录,但数据库中并没有保存任何字段。此外,node_save不会生成任何类型的错误 知道这里发生了什么吗 这是存储节点的函数: function

我刚刚偶然发现了非常奇怪的行为。在我的代码中,我用一些字段保存新节点。我必须说,这种方法过去运作得非常好。然而,现在它只是停止工作。我使用devel模块打印出对象和变量的内容,这是我的代码:

第一个dsm函数显示我创建的节点对象以及它应该显示的节点对象。第二个dsm函数显示完全正确的节点对象,并填充nid、字段内容等。。。然而,尽管{node}表中有新记录,但数据库中并没有保存任何字段。此外,node_save不会生成任何类型的错误

知道这里发生了什么吗

这是存储节点的函数:

function manhattan_incident_save($data) {
if ($data['nid']) {
  $node = node_load($data['nid']);
  manhattan_compare_changes($node, $data);
}
else {
  $node = new stdClass();
  $node->type = 'incident';
  node_object_prepare($node);

  $node->title = manhattan_create_incident_id();
  $node->language = LANGUAGE_NONE;      
}

$node->field_incident_popis[$node->language][0]['value'] = $data['field_incident_popis'];
$node->field_incident_popis[$node->language][0]['safe_value'] = check_plain($data['field_incident_popis']);

$node->field_incident_agent[$node->language][0]['uid'] = isset($data['field_incident_agent'])?intval($data['field_incident_agent']):NULL;

$node->field_incident_zdroj[$node->language][0]['tid'] = intval($data['field_incident_zdroj']);
$node->og_group_ref[$node->language][0]['target_id'] = $data['field_incident_oblast']?intval($data['field_incident_oblast']):variable_get('manhattan_public_form_default_area_nid', NULL);
$node->field_incident_riesitel[$node->language][0]['uid'] = isset($data['field_incident_riesitel'])?intval($data['field_incident_riesitel']):NULL;
$node->field_incident_typ[$node->language][0]['tid'] = intval($data['field_incident_typ']);
$node->field_incident_doplnenie[$node->language][0]['nid'] = intval($data['field_incident_doplnenie']);
$node->field_incident_sposob_kontaktu[$node->language][0]['value'] = $data['field_incident_sposob_kontaktu'];
$node->field_incident_dovod_vzniku[$node->language][0]['tid'] = intval($data['field_incident_dovod_vzniku']);

if ($data['field_incident_suvisiaci_zaznam']) {
  foreach ($data['field_incident_suvisiaci_zaznam'] as $file) {
    $result = manhattan_save_files($file);
    if ($result) {
      $node->field_incident_suvisiaci_zaznam[$node->language][] = array('nid' => $result); 
    }
  }
}

// now create/save the customer
if (function_exists('customer_customer_save')) {
  $customer = $data;
  $customer['nid'] = $data['field_incident_customer'];
  $result = customer_customer_save($customer); 
  if ($result) {
    watchdog('upvs', $result['message'], array(), WATCHDOG_NOTICE);
  }
  else {
    watchdog('upvs', t('There was a problem with saving customer %nid'), array('%nid' => $data['nid']), WATCHDOG_ERROR);
  }
}
// now we store nid of saved customer to the node object
$node->field_incident_customer[$node->language][0]['nid'] = $result['nid'];

dsm($node);
node_save($node); 
dsm($node);

if ($data['nid']) {
  watchdog('upvs', t('Incident number %title has been succesfully saved.'), array('%title' => $node->title), WATCHDOG_NOTICE);
}
else {
  watchdog('upvs', t('Incident number %title has been succesfully created.'), array('%title' => $node->title), WATCHDOG_NOTICE);
}

return $node;
}

是否确实正确准备了节点对象?你能否提供更多的细节,比如你是如何给对象添加值的?100%确定。它在一两天前就开始工作了。。。尽管如此,我已经编辑了原始文本,所以在现在包含的代码以及,你可以看看。同样,在保存之后,我在{node}表中得到了正确填充的节点对象和正确的记录。这些字段根本没有存储。因此,如果我理解正确的话,node_save现在不起作用,即使从那时起没有代码更改。这很奇怪。您可以检查日志吗?当然,在其他地方还有一些其他更改,但重点是node_save返回完全有效的node对象,没有错误,日志中没有任何内容,但它只是不将字段数据保存到数据库中。是的,很奇怪。你能检查一下存储这些字段数据的表的运行状况吗?
function manhattan_incident_save($data) {
if ($data['nid']) {
  $node = node_load($data['nid']);
  manhattan_compare_changes($node, $data);
}
else {
  $node = new stdClass();
  $node->type = 'incident';
  node_object_prepare($node);

  $node->title = manhattan_create_incident_id();
  $node->language = LANGUAGE_NONE;      
}

$node->field_incident_popis[$node->language][0]['value'] = $data['field_incident_popis'];
$node->field_incident_popis[$node->language][0]['safe_value'] = check_plain($data['field_incident_popis']);

$node->field_incident_agent[$node->language][0]['uid'] = isset($data['field_incident_agent'])?intval($data['field_incident_agent']):NULL;

$node->field_incident_zdroj[$node->language][0]['tid'] = intval($data['field_incident_zdroj']);
$node->og_group_ref[$node->language][0]['target_id'] = $data['field_incident_oblast']?intval($data['field_incident_oblast']):variable_get('manhattan_public_form_default_area_nid', NULL);
$node->field_incident_riesitel[$node->language][0]['uid'] = isset($data['field_incident_riesitel'])?intval($data['field_incident_riesitel']):NULL;
$node->field_incident_typ[$node->language][0]['tid'] = intval($data['field_incident_typ']);
$node->field_incident_doplnenie[$node->language][0]['nid'] = intval($data['field_incident_doplnenie']);
$node->field_incident_sposob_kontaktu[$node->language][0]['value'] = $data['field_incident_sposob_kontaktu'];
$node->field_incident_dovod_vzniku[$node->language][0]['tid'] = intval($data['field_incident_dovod_vzniku']);

if ($data['field_incident_suvisiaci_zaznam']) {
  foreach ($data['field_incident_suvisiaci_zaznam'] as $file) {
    $result = manhattan_save_files($file);
    if ($result) {
      $node->field_incident_suvisiaci_zaznam[$node->language][] = array('nid' => $result); 
    }
  }
}

// now create/save the customer
if (function_exists('customer_customer_save')) {
  $customer = $data;
  $customer['nid'] = $data['field_incident_customer'];
  $result = customer_customer_save($customer); 
  if ($result) {
    watchdog('upvs', $result['message'], array(), WATCHDOG_NOTICE);
  }
  else {
    watchdog('upvs', t('There was a problem with saving customer %nid'), array('%nid' => $data['nid']), WATCHDOG_ERROR);
  }
}
// now we store nid of saved customer to the node object
$node->field_incident_customer[$node->language][0]['nid'] = $result['nid'];

dsm($node);
node_save($node); 
dsm($node);

if ($data['nid']) {
  watchdog('upvs', t('Incident number %title has been succesfully saved.'), array('%title' => $node->title), WATCHDOG_NOTICE);
}
else {
  watchdog('upvs', t('Incident number %title has been succesfully created.'), array('%title' => $node->title), WATCHDOG_NOTICE);
}

return $node;
}