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
Files: 
CommentFileSizeAuthor
#4 1427040-instantiate-behavior.patch7.2 KBDamien Tournoud
PASSED: [[SimpleTest]]: [MySQL] 66 pass(es).
[ View ]
#2 1427040-instantiate-behavior-er-2.patch2.33 KBAmitaibu
PASSED: [[SimpleTest]]: [MySQL] 66 pass(es).
[ View ]

Comments

I'll give it a shot.

Status:Active» Needs review
StatusFileSize
new2.33 KB
PASSED: [[SimpleTest]]: [MySQL] 66 pass(es).
[ View ]

> 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.

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?

StatusFileSize
new7.2 KB
PASSED: [[SimpleTest]]: [MySQL] 66 pass(es).
[ View ]

Proposed patch.

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).

Looks good, thanks!

Status:Fixed» Closed (fixed)

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