From cb73ea2614e3e429c6b7a598d989b95cb6935170 Mon Sep 17 00:00:00 2001 From: Tim Plunkett Date: Thu, 10 Mar 2011 15:48:44 -0600 Subject: [PATCH] Issue #1084268 by tim.plunkett: Fix invalid field name. --- field_collection.module | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/field_collection.module b/field_collection.module index 055ef0a..f23341d 100644 --- a/field_collection.module +++ b/field_collection.module @@ -102,6 +102,9 @@ class FieldCollectionItemEntity extends EntityDB { public function __construct(array $values = array(), $entityType = NULL) { parent::__construct($values, 'field_collection_item'); + if (empty($values)) { + return; + } $this->fieldInfo = field_info_field($this->field_name); if (!$this->fieldInfo || $this->fieldInfo['type'] != 'field_collection') { throw new Exception("Invalid field name given."); @@ -113,6 +116,9 @@ class FieldCollectionItemEntity extends EntityDB { * field-collection item. */ public function fieldInfo() { + if (empty($this->fieldInfo)) { + $this->fieldInfo = field_info_field($this->field_name); + } return $this->fieldInfo; } @@ -151,7 +157,7 @@ class FieldCollectionItemEntity extends EntityDB { */ public function path() { if ($this->item_id) { - return field_collection_field_get_path($this->fieldInfo) . '/' . $this->item_id; + return field_collection_field_get_path($this->fieldInfo()) . '/' . $this->item_id; } } -- 1.7.3.2