Thanks for maintaining what has become a vital module!
A few notes:

  • The error does not appear when I'm a logged in as an admin.
  • when I remove nofollow from the rel attribute in settings for my link field, the error goes away.
  • I think that strpos wants an string, but $item['attributes']['rel'] is an array.

Comments

kpa’s picture

You are right, strpos expects a string. I'm not sure why/what module is putting forwards $item['attributes']['rel'] as an array of ['rel'], but this code fixes the problem.

In ../modules/link/link.module

<?php
// line 516: 
  // Remove the rel=nofollow for internal links.
  if ($type != LINK_EXTERNAL && strpos($item['attributes']['rel'], 'nofollow') !== FALSE) {
    $item['attributes']['rel'] = str_replace('nofollow', '', $item['attributes']);
  }
?>

Change to:

<?php
  if(is_array($item['attributes']['rel'])) {
    $item['attributes']['rel'] = $item['attributes']['rel']['rel'];
  }
  // Remove the rel=nofollow for internal links.
  if ($type != LINK_EXTERNAL && strpos($item['attributes']['rel'], 'nofollow') !== FALSE) {
    $item['attributes']['rel'] = str_replace('nofollow', '', $item['attributes']);
  }
?>

For those interested, the $item['attributes']['rel']['rel'] element is a duplicate of the parent array. Somewhere, something is setting

<?php
$rel = $item['attributes']['rel'];
$item['attributes']['rel']['rel'] = $rel;
...
?>
deborra-1’s picture

I too hit this problem, and may have some info that could help better identify the root.

I let folks input urls and check them in my code with the Drupal API method valid_url(). Even with this check, bad URLs could be input including http://www.mfg-6/Widget. This URL caused the problem. When I fixed the URL to http://www.mfg-6.com/Widget, the problem went away. I tried several times to ensure that this was indeed causing and "fixing" the problem. Hopefully it is not a red herring.

tomceek’s picture

// Remove the rel=nofollow for internal links.

I have removed that option from link module, but my need is to have nofollow attribute even for internal links too so it would be nice to have it as function in module settings.

dqd’s picture

Status: Active » Closed (duplicate)

I have to agree with what tomceek says, and have opened another issue for that #1441702: Rel attribute should have an option to get automaticly turned on/off if link is internal/external,

... since it isn't only useful for the condition that the link is internal, but also if the link is external in some cases. So it needs a more complete solution for rel attribute getting turned on/off, if the link is internal or external. The patch is provided in this http://drupal.org/node/1441702#comment-5607360 and even if the rules say to rather close the new issue for the old one, I close this issue here, since it should be solved by the patch for a new solution, and I would like to lead you over there to test the patch to commit it as soon as possible.