Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
entity_reference.module
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
21 Feb 2015 at 11:17 UTC
Updated:
16 Mar 2015 at 00:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
geertvd commentedComment #2
geertvd commentedComment #3
geertvd commentedComment #4
geertvd commentedThis should probably be a static method also.
Comment #5
geertvd commentedComment #6
geertvd commentedComment #7
geertvd commentedComment #8
geertvd commentedAdded test and made
settingsFormValidatea static method.Comment #9
geertvd commentedComment #14
geertvd commentedComment #15
geertvd commentedComment #17
amateescu commentedThe patch and test looks great, just one tiny nitpick:
We don't need to enable the views_ui module :)
Comment #18
geertvd commentedActually, this is an issue I bumped into while writing the test, at the moment views_ui needs to be enabled because we are printing
Url::fromRoute('views_ui.add')hereHow do you propose we should fix that? It's a bit silly that views_ui needs to be enabled for this.
Comment #19
geertvd commentedForgot to take an interdiff but this is what I added
Comment #20
amateescu commentedIf we're going down this path, the current_user and module_handler services can be injected in the plugin.
Comment #22
geertvd commentedSomething like this then
Comment #23
amateescu commentedPerfect!
Comment #24
alexpottWhy does #element_validate have to be static? I.e can't we do
Comment #25
amateescu commentedBy declaring element validate (also process, etc.) handlers as a static methods we skip a lot of form object serialization. Field API does this consistently all over the place :)
Comment #26
alexpottHuh http://3v4l.org/S0onn?
Comment #27
alexpottBasically I don't get the argument in #25 - using $this will not save any form serialisation and if the form is serialised the object detection in serialisation might well end up being more memory efficient that storing the classname.
Comment #28
amateescu commentedWhen you start adding objects (e.g. entities, services) to $d, all of them will need to go through the serialization process, while the simple
array(array('\some\class\name', 'someMethod'))will not.Comment #29
alexpottYeah but this is $this
Comment #30
amateescu commentedI don't understand #29.
Comment #31
geertvd commentedJust changed
to
I guess this makes sense, since settingsFormValidate is only called from within
ViewsSelectionI don't see why it should be static.Comment #32
alexpottre #29 - there is no saving when doing get_called_class($this) because $this is what is being serialised.
Comment #33
berdirIt's not the $this that is serialized. It's $form, containing references to $this. And if we make that static, then we can avoid that being serialized. As @amateescu said, field api widgets use that pattern a lot.
Being able to do this is one of the main reasons I introduced support for '::methodName' , but that only works in the actual form objects.
See http://3v4l.org/ALTTj
Comment #34
fabianx commentedI agree that we should serialize as less as possible to avoid deep-object-references.
Comment #35
alexpottOk get_called_class it is - not going to fight - but it makes code less testable and dependencies less obvious.
We have object serialization going on all over the place.
Comment #36
geertvd commentedSame patch as in #22
Comment #37
amateescu commentedComment #38
webchickLooks like Alex has been all over this one.
Comment #39
alexpottThis issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 9dfa950 and pushed to 8.0.x. Thanks!