Link Checker is not compatible with the Field Collections module.

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
StatusFileSize
new1.35 KB

Hi Guys, patch ready

samvel’s picture

was small mistake. new patch appended

mdixoncm’s picture

Issue summary: View changes
StatusFileSize
new1.58 KB

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

Anonymous’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 :-)

quadrexdev’s picture

Status: Needs review » Closed (outdated)

D7 reached its EOL back in January 2025, and there is no active release for D7 for this module anymore.
Development or support is not planned for D7. All D7-related issues are marked as outdated in a bunch.

If the issue remains relevant for D10+ versions, merge requests with proposed solutions for a new module version (D10+) are welcome in a new follow-up issue.

Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.