Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony bootstrap cleanup, the new 'kernel.reset' tag should do the job #144

Merged
merged 1 commit into from
Jan 7, 2020

Conversation

acasademont
Copy link
Contributor

All the custom hijacking shouldn't be needed anymore afther SF 3.4 added the kernel.reset tag. Not so sure about the logger and swiftmailer hijacks

@acasademont
Copy link
Contributor Author

Tests are failing because the Kernel mock explicitly throws an exception if bundles have not been initialized before the first request. Symfony boots the Kernel on the first request, so I'm not sure if those tests are still relevant...ping @marcj

@acasademont
Copy link
Contributor Author

I believe that hacky bundle initialization was done in order to do some stuff with the session service a while ago, but that hack is no longer in place

@marcj
Copy link
Member

marcj commented Nov 28, 2018

The tag is only used when we'd call kernel->reset, which we don't. The thing is, when you reset the kernel and throw with it all service, basically the whole performance gain is gone as well.

@dnna
Copy link
Contributor

dnna commented Nov 28, 2018

@marcj actually this tag is used in https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Kernel.php#L110, it is not related with kernel->reset.

Personally I think this PR makes sense with Symfony > 3, but is there a way to verify that the profiler is still working the same with the removed lines?

@marcj
Copy link
Member

marcj commented Nov 28, 2018

Oh, you're right, sorry about that. :)

Is services_resetter resetting the container or does it send a reset event to subscribers? If so, Symfony should've already covered a couple stuff we tried to fix via hacks.

but is there a way to verify that the profiler is still working the same with the removed lines?
I guess we can only test that currently manually.

@dnna
Copy link
Contributor

dnna commented Nov 28, 2018

It doesn't reset the container, it just iterates the services tagged with kernel.reset and calls the reset method on them.

I think it covers most of stuff we fixed through hacks. In fact with, Symfony 4, most of the hack code doesn't even get executed because most services are no longer public :)

@acasademont
Copy link
Contributor Author

acasademont commented Nov 28, 2018 via email

@andig
Copy link
Contributor

andig commented Nov 28, 2018

@marcj would like to leave this with you ;)

@andig andig requested a review from marcj November 28, 2018 16:51
@marcj
Copy link
Member

marcj commented Nov 28, 2018

All up to you @andig, I haven't developed PHP for quite some time. :P
But that reset tag sounds very good and goes directly in PHP-PM's direction. Love it :) We should test however if that stuff we covered via hacks still works after this PR 💃

@acasademont
Copy link
Contributor Author

acasademont commented Nov 29, 2018

All the removed hacks have been tested with SF 4 only. I'd still like to know what you want to do with the tests.

I believe @dnna was working on a patch to make it work with symfony/monolog-bundle#279 so after that another of the hacks could be removed

@acasademont
Copy link
Contributor Author

Actually @dnna PR doesn't seem related sorry! Seems like the getDebugLogger hack could also be removed, as that is triggered by the LoggerDataCollector clear which is triggered by the kernel.reset tag on the Profiler

@andig
Copy link
Contributor

andig commented Nov 30, 2018

Regarding marc's comment:

We should test however if that stuff we covered via hacks still works after this PR 💃

Is there any way we can unit-test this before/after? For all affected services? As admitted before- I personally have no idea about Symfony :(

@acasademont
Copy link
Contributor Author

I'll take a look at it. It shouldn't be too difficult to make those tests.

@andig
Copy link
Contributor

andig commented Jan 2, 2019

ping @acasademont is this still something you're interested in?

@acasademont
Copy link
Contributor Author

Yes, but I totally forgot about it :p I'll try to make them work during this weekend :)

@acasademont
Copy link
Contributor Author

First step to bulding relevant tests is at #152

@andig
Copy link
Contributor

andig commented Jan 20, 2019

@acasademont I understand we want to merge this after #152 to verify it still tests, right? Can we merge this one as part of a bugfix release? Please note that it also has conflict currently.

Btw., you can also remove the PHPPM\Symfony\StrongerNativeSessionStorage, its no longer utilized after this PR.

@acasademont
Copy link
Contributor Author

@andig yes, but more tests are needed for that, #152 just lays the foundation for this future tests. Probably I should add them on the other PR and make the refactor in this one.

@acasademont
Copy link
Contributor Author

And yes, this could be a minor/patch release, we're doing nothing fancy, just removing stuff

@andig andig added this to the 2.0 milestone Feb 4, 2019
@andig
Copy link
Contributor

andig commented Mar 6, 2019

ping @acasademont is this something you want to get into upcoming 2.0?

@acasademont
Copy link
Contributor Author

Yes, I just need to make some time for it :(((

@andig
Copy link
Contributor

andig commented Jan 5, 2020

Is this something we could get into a 2.1 release really soonish?

@acasademont
Copy link
Contributor Author

@andig I cleand up a bit the tests and rebased with master. Some doubts though:

  • Until when do we keep those checks. For example, the webpack bundle now already implements the ResetInterface but as I don't use it, I'm not sure when should we remove that check. ping @fionera
  • Also, going forward, we shouldn't add all these in the core Symfony bootstrap, there are potentially an infinite number of libraries that need some kind of reset post-request, people should be able to extend and create their own bootstrap and reset their stuff there. On the core Symfony we should only deal with core Symfony stuff.

@andig
Copy link
Contributor

andig commented Jan 5, 2020

Until when do we keep those checks.

Totally up to you. I really have no idea about the Symfony part :/

Also, going forward, we shouldn't add all these in the core Symfony bootstrap

Agreed, but that would need a new mechanism and is outside of this PR's scope.

So... merge for time being?

@acasademont
Copy link
Contributor Author

Yes, I just removed the webpack checks too.

Travis seems to be failing due to a weird constraint. I don't really understand why we do install symfony & drupal for the tests. any ideas @andig ?

@andig
Copy link
Contributor

andig commented Jan 7, 2020

For static analysis: https://github.com/php-pm/php-pm-httpkernel/blob/master/.travis.yml#L19. Need to add an update dependencies flag for that to work again.

@andig andig merged commit 8ce93b9 into php-pm:master Jan 7, 2020
@andig
Copy link
Contributor

andig commented Jan 7, 2020

See composer/composer#8518 for the ci error

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

Successfully merging this pull request may close these issues.

4 participants