When a node has a empty body I get the following 2 error, when SAVING a node with an empty body:

Notice: Undefined offset: 0 in _icl_wrapper_check_node_body() (line 811 of /Applications/MAMP/htdocs/zoetis/sites/all/modules/contrib/translation_management/icl_core/icl_core.wrapper.inc).
Notice: Undefined offset: 0 in _icl_wrapper_check_node_body() (line 812 of /Applications/MAMP/htdocs/zoetis/sites/all/modules/contrib/translation_management/icl_core/icl_core.wrapper.inc).

In the use case, the $node->body[$node->language] is set to an empty array. So "$body = $node->body[$node->language][0]['value'];" throws a warning.

PS: This is a great module.

CommentFileSizeAuthor
#1 translation_management.1815710.1.patch491 bytesBill Choy

Comments

Bill Choy’s picture

Need to replace the "isset()" test with a "! empty()".
If the body is empty, then $node->body[$node->language] is set, but its an empty array.

function _icl_wrapper_check_node_body(&$node) {
-  if (isset($node->body[$node->language])) {
+  if (!empty($node->body[$node->language])) {
     $body = $node->body[$node->language][0]['value'];
     $format = $node->body[$node->language][0]['format'];
     $node->body = $body;
     $node->format = $format;
  } else {
    $node->body = '';
    $node->format = '';
  }
}
hectorelgomez’s picture

Thanks it works!

line 809, translation_manager/icl_core/icl_core.wrapper.inc

hectorelgomez’s picture

Issue summary: View changes

Updated issue summary.