There are numerous issues around behavior instantiation:

  • The constructor of the behavior gets passed $field and (sometimes) $instance, but we cache the behaviors per class in _entityreference_get_behavior_handler()
  • EntityReference_BehaviorHandler_Abstract::__construct() tries to load the settings from a bogus array keys, and as a consequence $this->settings is always empty
  • We pass $field and $instance to the constructor, but we also pass those to every method. We should do one or the other, not both
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

amitaibu’s picture

I'll give it a shot.

amitaibu’s picture

Status: Active » Needs review
FileSize
2.33 KB

> We pass $field and $instance to the constructor, but we also pass those to every method.

Let's keep passing the $field and $instance to all the field modules methods , e.g load(), persave(), to keep the function signature consistent. To our own methods, e.g. access() - I've remove them.

Damien Tournoud’s picture

Because we need to pass $field and $instance to the field methods, I would prefer to pass $field and/or $instance to every methods. Any objection?

Damien Tournoud’s picture

Proposed patch.

Damien Tournoud’s picture

Status: Needs review » Fixed

I actually pushed this by mistake, but I don't see how it could not work for OG (of course it is a slight API change, but the current behavior is completely broken).

amitaibu’s picture

Looks good, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.