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

Update resetScope to forgetScopedInstances in Listeners/FlushTemporaryContainerInstances #500

Closed
coleshirley opened this issue Mar 30, 2022 · 1 comment

Comments

@coleshirley
Copy link

  • Octane Version: ^1.0.5
  • Laravel Version: ^8.47.0
  • PHP Version: 8.0
  • Server & Version: Swoole / RoadRunner Any
  • Database Driver & Version: Any

Description:

In this commit: laravel/framework@2971b64 the resetScope() method on the container class was changed to forgetScopedInstances() but this change was never reflected in Octane in https://github.com/laravel/octane/blob/1.x/src/Listeners/FlushTemporaryContainerInstances.php

Solution

<?php

namespace Laravel\Octane\Listeners;

class FlushTemporaryContainerInstances
{
    /**
     * Handle the event.
     *
     * @param  mixed  $event
     * @return void
     */
    public function handle($event): void
    {
        if (method_exists($event->app, 'resetScope')) {
            $event->app->resetScope();
        }
 
        // Add this section
        if (method_exists($event->app, 'forgetScopedInstances')) {
            $event->app->forgetScopedInstances();
        }

        foreach ($event->sandbox->make('config')->get('octane.flush', []) as $binding) {
            $event->app->forgetInstance($binding);
        }
    }
}
@driesvints
Copy link
Member

Thanks for noting this. I sent in a PR: #501

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

No branches or pull requests

2 participants