Getting following notices on the node edit form:

Undefined index: format in linkchecker_parse_fields() (line 1053 of /www/sites/all/modules/contrib/linkchecker/linkchecker.module).

and

Notice: Undefined index: und in _linkchecker_add_node_links() (line 611 of /www/sites/all/modules/contrib/linkchecker/linkchecker.module).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wojtha’s picture

Status: Active » Needs review
FileSize
2.19 KB

This patch should fix these notices.

hass’s picture

Any reason that you are not using empty()?

hass’s picture

Status: Needs review » Fixed

http://drupalcode.org/project/linkchecker.git/commit/8b29a7c
http://drupalcode.org/project/linkchecker.git/commit/ac5ba7b

I've changed the patch for the first lines a bit. Thank you very much for the patch!

wojtha’s picture

@hass: isset() is sufficient in this case. It doesnt matter if the value is NULL, we just need to check if the array key exists.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

johnbarclay’s picture

Status: Closed (fixed) » Needs work

same problem in 'text_with_summary' fields in linkchecker.module. While the value field is always populated, the summary is not.

- $text_items[] = _linkchecker_check_markup($item['summary'], $format, $entity->language, TRUE);
+ $text_items[] = isset($item['summary']) ? _linkchecker_check_markup($item['summary'], $format, $entity->language, TRUE) : NULL;

hass’s picture

hass’s picture

How can I repro this? I also have nodes with empty summary, but don't see a notice.

hass’s picture

Status: Needs work » Postponed (maintainer needs more info)

Cannot repro with Drupal 7.12.

dgtlmoon’s picture

I'm getting this error with Drupal 7.14 whilst running some Drush tests, however i'm not sure what the cause is just yet

linkchecker_parse_fields() failed: Undefined index: summary

hass’s picture

What are "some tests from drush"? I need a repro plan.

dgtlmoon’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Turns out the drush warnings i was having was due to another test that was using drupalCreateNode and not setting a 'summary'

Alan D.’s picture

Issue summary: View changes
Status: Closed (won't fix) » Needs review
FileSize
1.39 KB

Devel generate triggers these errors too.

This is triggered during save, so I would think that anything that passes field_is_empty() is valid input and needs to be handled here.

i.e.

  $node = new stdClass();
  $node->type = 'webform';
  node_object_prepare($node);
  $node->uid = 1;
  $node->title = 'Contact Us';
  $node->language = LANGUAGE_NONE;
  $node->body['und'][0] = array('value' => '', 'format' => 'html');
  $node->path['alias'] = 'contact-us';
  node_save($node);

This code throws notices: Notice: Undefined index: summary in _linkchecker_parse_fields() (line 1550 of sites\all\modules\linkchecker\linkchecker.module).

Format is checked, a vital text property, so I'm not sure why an optional property is not.

hass’s picture

Type is text_with_summary, but summary is not set??? Sound like a webform bug...

Alan D.’s picture

I have seen this with custom code, devel generate, randomly on save (I think field permissions were in play)... It is one of the few remaining issues in a "base install" I'm working on, with a mere 150 modules....

hass’s picture

Yeah, but there must be something wrong. The field type is text_with_summary and this means there need to be a summary. Otherwise it should be text_long or text. Maybe devel generate has a bug or webform has...

How can I reproduce this reliable? It is 100% caused by webform? webform 3 or webform 4?

Alan D.’s picture

Custom code example above will generate a 100% PHP notice. Node type is irrelevant. On 50 nodes, I get about 30 warnings from Devel Generate, probably as it randomly sets about 30 teasers.

Note. Justification for this can also be found in core:

function text_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
....
  switch ($instance['widget']['type']) {
....
    case 'text_textarea_with_summary':
      $display = !empty($items[$delta]['summary']) || !empty($instance['settings']['display_summary']);
      $summary_widget = array(
        '#type' => $display ? 'textarea' : 'value',
        '#default_value' => isset($items[$delta]['summary']) ? $items[$delta]['summary'] : NULL,
.....
  }
....
}

i.e. Even core does not trust that the summary value is set.

hass’s picture

+++ b/linkchecker.module
@@ -1549,9 +1549,13 @@ function _linkchecker_parse_fields($entity_type, $bundle_name, $entity, $return_
+            $item['summary'] = isset($item['summary']) ? $item['summary'] : '';

Code wise I would say we do not need this line, isn't it?

hass’s picture

Status: Needs review » Fixed

Extended this a bit and committed http://drupalcode.org/project/linkchecker.git/commit/799ee7c

Could you test this, please?

Alan D.’s picture

At the point within the code, a dpm() shows correct field format, and no more errors in Devel generate :)

Thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jelo’s picture

This issue still persists. I just ran into, but have trouble pinpointing it. My suspicion is that it might have to do with nodes that have been created through feeds module. My importer set the body field for a content type, but nothing for the summary. Are you saying that every time a field "text plus summary" is set programmatically or through a module (such as feeds or rules), the summary needs to be set at the same time, otherwise this error will show?