Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
13 Jun 2014 at 09:11 UTC
Updated:
7 Nov 2014 at 13:21 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
znerol commentedThis currently contains #2281903: Refactor DrupalKernel::initializeContainer in preparation of a replacement for persist services and #2277481: Remove persist flag from container.namespaces service. Let's first discuss the approach taken here.
Comment #3
alexpottI don't get all the complexity here. Why don't we just have an interface that services can implement that as the methods
getState()andrestoreState(). In DrupalKernel we can detect services that implement this interface and store their state using getState() and once the container is rebuilt userestoreState()to get the service into the correct state. For synthetic services we could just detect them and copy them in a similar way we do for persistent - although will we have any synthetic services once the request is removed?Comment #4
znerol commentedWe cannot delegate the responsibility for maintaining the state to services themselves because of the following reasons:
As an example of how this patch actually reduces complexity, here is
DrupalKernel::initializeContainer()afterwards:Also it should be mentioned, that state-recording can be used if it is necessary to instantiate a whole new container (like for example in
WebTestBase):Comment #5
znerol commentedIds of synthetic services need to be collected during a compiler pass.
Comment #7
znerol commentedReroll after #2277481: Remove persist flag from container.namespaces service.
Comment #9
znerol commentedNeed to ensure that
request_stackis also in the container fromTestBase, now thatWebTestBase::rebuildContainerdoes not special case maintenance of the container state anymore.Comment #10
fabpot commentedMy 2 cents here: The idea of persisting services is flawed and very dangerous. It should be removed altogether and not replaced with anything.
As of today, there are 7 services that are "persisted" between container rebuilds:
Only the first three ones are synthetic services.
Persisting
service_containeris very wrong as the new container will then get the old container in theservice_containerservice. So, whenever a service depends on theservice_containerservice, it's going to receive the old container, not the new one... or I'm missing something here.Persisting the
kernelis not needed as it's already done when building the container.The
container.namespacesis not a service and should be removed (as mentioned in other issues.)The
session_manageris also very interesting. As it depends on many other objects, it will keep the objects from the old container, not the new ones as those dependencies are not persisted.So, my point is that whatever you do here, it's going to be wrong for most cases. That's why instead of trying to replace it, it should be removed. From my understanding, persisted objects are only useful when some modules are added from the UI (and
updateModules()is called). But in this case, why not flush the cache and immediately redirect the user so that you get a fresh container for the very next request?I'm pretty sure I'm missing something here, but as to me, this is a major flaw in the way the container is managed currently.
Comment #11
znerol commentedThey actually always contain fresh instances. The persist logic checks whether a service is already initialized, if yes it is not restored (overwritten) with the old instance.
Not anymore as of #2277481: Remove persist flag from container.namespaces service.
This is exactly the reason why I'm working on this issue in the first place, see #2272987: Do not persist session manager.
Regrettably the installer also relies on that, and because the test-runner (UI and CLI) relies on the installer, all of the integration tests depend on a mechanism capable of persisting state of some services across container rebuilds.
Comment #12
olli commentedRe #10
Filed #2286291: Remove container.namespaces service.
Comment #13
alexpottTotally agree with @fabpot - I've been trying to remove persisted services for ages. I think we should move forward with the latest patch on #2272987: Do not persist session manager and once that is in just remove persisted services. I've proved in earlier issues (before the session manager was a service) that we don't need it.
Comment #14
catchGetting rid of persisted services altogether sounds great if we can do it.
Comment #15
znerol commentedClosing this in favor of #2368263: Remove the persist service tag