commit 0a5e19dc612324c13cc83ffa8dec527e4518b221 Author: Pieter Frenssen Date: Thu Jun 5 19:02:03 2014 +0200 1837650-47 diff --git a/entityreference.module b/entityreference.module index 4484799..6e40277 100644 --- a/entityreference.module +++ b/entityreference.module @@ -244,7 +244,7 @@ function entityreference_field_validate($entity_type, $entity, $field, $instance */ function entityreference_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) { // Reference the right revision(s) if revisions are being tracked. - if (!empty($instance['settings']['handler_settings']['reference_revisions'])) { + if (!empty($field['settings']['handler_settings']['reference_revisions'])) { $target_type = $field['settings']['target_type']; // It is possible this is an existing entity which is being updated. If this @@ -262,7 +262,7 @@ function entityreference_field_presave($entity_type, $entity, $field, $instance, $revision_id = NULL; // If the revisions are locked, make sure they do not change. - if (!empty($instance['settings']['handler_settings']['lock_revision'])) { + if (!empty($field['settings']['handler_settings']['lock_revision'])) { // Get the revision ID from the original item. If that is not set get it // from the current item. $revision_id = !empty($item['revision_id']) ? $item['revision_id'] : NULL; diff --git a/tests/entityreference.revisions.test b/tests/entityreference.revisions.test index b0809a1..0d156ed 100644 --- a/tests/entityreference.revisions.test +++ b/tests/entityreference.revisions.test @@ -11,6 +11,13 @@ class EntityReferenceRevisionsTestCase extends DrupalWebTestCase { protected $profile = 'testing'; /** + * The entityreference field. + * + * @var array + */ + protected $field; + + /** * The entityreference field instance. * * @var array @@ -61,7 +68,7 @@ class EntityReferenceRevisionsTestCase extends DrupalWebTestCase { 'field_name' => 'field_entityreference', 'type' => 'entityreference', ); - $field = field_create_field($field); + $this->field = field_create_field($field); // Create a field instance. $instance = array( @@ -99,8 +106,8 @@ class EntityReferenceRevisionsTestCase extends DrupalWebTestCase { // Enable revision referencing and update the referencing node so it picks // up the change. - $this->instance['settings']['handler_settings']['reference_revisions'] = TRUE; - field_update_instance($this->instance); + $this->field['settings']['handler_settings']['reference_revisions'] = TRUE; + field_update_field($this->field); node_save($this->referencing_node); // Check that the field is now referencing revisions. Retrieve the revision @@ -116,8 +123,8 @@ class EntityReferenceRevisionsTestCase extends DrupalWebTestCase { // Enable revision locking and update the referencing node so it picks up // the change. - $this->instance['settings']['handler_settings']['lock_revision'] = TRUE; - field_update_instance($this->instance); + $this->field['settings']['handler_settings']['lock_revision'] = TRUE; + field_update_field($this->field); node_save($this->referencing_node); // When a new revision is created the referencing node should now remain @@ -145,7 +152,7 @@ class EntityReferenceRevisionsTestCase extends DrupalWebTestCase { * The referenced revision. * * @throws Exception - * Thrown if the referenced node is not referencing a revision. + * Thrown if the referencing node is not referencing a revision. */ protected function getReferencedRevisionId() { $items = field_get_items('node', $this->referencing_node, 'field_entityreference');