Link Checker is not compatible with the Field Collections module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Status: Active » Postponed (maintainer needs more info)

Repro plan? Patch?

hass’s picture

Issue tags: -Field collection
hass’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Postponed (maintainer needs more info) » Active

Reproduced this and made a node dump that shows that only a reference is visible in the node object and not the raw data. This does not integrate in current logic's and requires a lot of extra work. I'm not going to work on this myself.

larowlan’s picture

So to get this going, apply #1946252: Create hooks to allow modules to extract and replace links then add something like so in your custom module


/**
 * Implements hook_linkchecker_extract_node_links().
 */
function MYMODULE_linkchecker_extract_node_links($node) {
  $text_items = array();
  list($id, $revision, $bundle) = entity_extract_ids('node', $node);
  $instances = field_info_instances('node', $bundle);
  $wrapper = entity_metadata_wrapper('node', $node);
  foreach ($instances as $instance) {
    if (($field = field_info_field($instance['field_name'])) &&
        ($field['type'] == 'field_collection')) {
      foreach ($wrapper->{$instance['field_name']} as $item) {
        $text_items[] = render($item->view());
      }
    }
  }
  return $text_items;
}

Works a treat.

larowlan’s picture

So to get this going, apply #1946252: Create hooks to allow modules to extract and replace links then add something like so in your custom module


/**
 * Implements hook_linkchecker_extract_node_links().
 */
function MYMODULE_linkchecker_extract_node_links($node) {
  $text_items = array();
  list($id, $revision, $bundle) = entity_extract_ids('node', $node);
  $instances = field_info_instances('node', $bundle);
  $wrapper = entity_metadata_wrapper('node', $node);
  foreach ($instances as $instance) {
    if (($field = field_info_field($instance['field_name'])) &&
        ($field['type'] == 'field_collection')) {
      foreach ($wrapper->{$instance['field_name']} as $item) {
        $text_items[] = render($item->view());
      }
    }
  }
  return $text_items;
}

Works a treat.

Samvel’s picture

Status: Active » Needs review
FileSize
1.35 KB

Hi Guys, patch ready

Samvel’s picture

was small mistake. new patch appended

mdixoncm’s picture

Loving the patch - and it's working nicely - however, if you do end up with a broken link in the field collection then currently it is not possible to view this in the report - I have updated the patch to allow the linkchecker to add field_collection fields to the list of fields it does it's access control checks on ...

mstrelan’s picture

Perhaps it would be better for linkchecker to scan all entity types / bundles instead of just nodes.

aitala’s picture

This patch seems to work... but it does need to display broken links...

Eric

BWPanda’s picture

Patch from #8 works.

Client discovered a few broken links themselves, then asked why they weren't appearing on the 'Broken links' page. Turns out they were all in a field collection. Applying the patch and re-scanning the site resulted in 5 pages of broken links the client will now have to wade through :-)