Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Auto initialize fails #1

Open
sagikazarmark opened this issue Dec 20, 2014 · 11 comments
Open

Auto initialize fails #1

sagikazarmark opened this issue Dec 20, 2014 · 11 comments

Comments

@sagikazarmark
Copy link
Contributor

Using session with auto_initialize config set to true fails, because it tries to fetch an application component before it gets initialized.

@sagikazarmark
Copy link
Contributor Author

Session auto initialization is not a session config, but an application one. I propose to add it to the config.php. or somewhere into the application initialization process. This way we can remove the unnecessary dependency (application) from the session.

@WanWizard
Copy link
Contributor

Session needs the Application object because it needs to hook into it's Event manager. So the dependency is there, I suggest auto_initialize has to be fixed instead.

@sagikazarmark
Copy link
Contributor Author

What if we move the auto save thing to the application initialization? I think that the session does not really need to know about the actual saving process.

@WanWizard
Copy link
Contributor

I have to look into that. It might be that session has not evolved with changes in Foundation. Application does already process auto_initialize at the moment, the Session classes should indeed not be aware of that.

@WanWizard
Copy link
Contributor

I think this is exactly the problem. Application wants to create a Session Manager object in it's constructor, by calling the InjectionFactory, which in turn calls the Session ServiceProvider. That needs the currentComponent object, which isn't there, because Application is still being constructed.

@sagikazarmark
Copy link
Contributor Author

What if the SessionManager depends on a singleton instance of event manager instead? Because it only needs the application to hook into the event manager.

And I still think that the auto save is out of scope of session manager. Session manager needs to provide a way to save the session. The outside world needs to call it. So I'd move the event hook to the application initialization.

@sagikazarmark
Copy link
Contributor Author

If the Application processes auto_initialize, why can't it process the auto save as well? IMO the session manager should NOT rely on an application object.

@WanWizard
Copy link
Contributor

auto init is more of a v1 legacy, the question is if that should be kept. There are situations where you don't want the session to autostart (for example the table hasn't been created yet), currently that is quite complex. I do however think that once a session is started, it should be auto-saved.

Perhaps the session itself shout register itself for a shutdown event when started, en de-register when stopped. That would require the event instance to be injected in Session.

@sagikazarmark
Copy link
Contributor Author

I agree it should be autosaved. I am just not really fine with having something injected into the session manager. As I said, since it is created in the application (where auto init is decided as well), it could be registered there as well. However in this case the deregister is not possible from the session manager. Anyway, rather an event emitter than the whole application injected.

@WanWizard
Copy link
Contributor

You could split the problem.

When a new session object is initiated, always create a shutdown event entry for it. And then use enable/disable methods and a flag inside the Session manager to determine if that event actually does something?

@sagikazarmark
Copy link
Contributor Author

Hm, could work...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants