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

[10.x] Fixes view engine resolvers leaking memory #51450

Merged
merged 1 commit into from
May 17, 2024

Conversation

nunomaduro
Copy link
Member

This pull request fixes view engine resolvers leaking app instance in Octane: laravel/octane#887.

Note that I've spend a few time trying to write tests for this; but is not easy with our current Octane setup.

@driesvints This needs to be merged on 11.x.

@nunomaduro nunomaduro requested a review from taylorotwell May 17, 2024 15:59
@taylorotwell taylorotwell merged commit 087bf14 into 10.x May 17, 2024
27 checks passed
@taylorotwell taylorotwell deleted the chore/view-engine-resolvers-leaking-memory branch May 17, 2024 16:01
@@ -161,9 +161,14 @@ public function registerPhpEngine($resolver)
public function registerBladeEngine($resolver)
{
$resolver->register('blade', function () {
$compiler = new CompilerEngine($this->app['blade.compiler'], $this->app['files']);
$app = app();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driesvints @nunomaduro

As the app() helper is pulled from the Foundation component, doesn't the View component's composer.json file need to be updated to account for that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One option is to call Container::getInstance() as the app() helper basically does only that, and the Container component is already required by the view component.

For the other usage, Container::getInstance()->make($dependency) can be used.

function app($abstract = null, array $parameters = [])
{
if (is_null($abstract)) {
return Container::getInstance();
}
return Container::getInstance()->make($abstract, $parameters);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

3 participants