Error when saving nodes with link field

pcambra - July 15, 2009 - 11:01
Project:Link
Version:6.x-2.6
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

I am getting this error when I save a node:
( ! ) Fatal error: Cannot use string offset as an array in /webs/mysite.com/sites/mysite.com/modules/link/link.module on line 249

I've added a chek of is_array for $item['attributes'] in _link_process function

<?php
 
if (is_array($item['attributes'])) {
    if (!
$item['attributes']['target'] || $item['attributes']['target'] == "default") {
      unset(
$item['attributes']['target']);
    }
  }
?>

I am attaching a patch.

#1

pcambra - July 15, 2009 - 11:02

here is the patch

AttachmentSize
link-519848.patch 711 bytes

#2

dropcube - September 15, 2009 - 19:41
Version:6.x-2.6-beta3» 6.x-2.6
Status:active» needs review

Checking if the variable is an array fixes the problem, but the correct solution would be to initialize the attributes array so that we don't have is_array() checks everywhere in the code.

#3

dropcube - September 18, 2009 - 05:06
Status:needs review» postponed (maintainer needs more info)

Could you please check with the current development snapshot and report back if the issue continues ?

 
 

Drupal is a registered trademark of Dries Buytaert.