Skip to content

Update resetScope to forgetScopedInstances in Listeners/FlushTemporaryContainerInstances #500

@coleshirley

Description

@coleshirley
  • 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);
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions