Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ProcessMaker/ImportExport/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class Manifest

private static $logger = null;

public static function resetRequestState(): void
{
self::$parents = null;
self::$logger = null;
}

public function has(string $uuid)
{
return array_key_exists($uuid, $this->manifest);
Expand Down
2 changes: 2 additions & 0 deletions ProcessMaker/Octane/ResetRequestState.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace ProcessMaker\Octane;

use ProcessMaker\ImportExport\Manifest;
use ProcessMaker\Providers\ProcessMakerServiceProvider;
use ProcessMaker\Services\RedirectToEventService;

Expand All @@ -17,6 +18,7 @@ public function __construct(
public function handle(): void
{
ProcessMakerServiceProvider::beginRequestTiming();
Manifest::resetRequestState();
$this->redirectToEventService->reset();
}
}
7 changes: 7 additions & 0 deletions tests/Feature/ImportExport/ManifestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ class ManifestTest extends TestCase
{
use HelperTrait;

protected function tearDown(): void
{
Manifest::resetRequestState();

parent::tearDown();
}

private function mockExporter($dependents)
{
return $this->mock(ScreenExporter::class, function ($mock) use ($dependents) {
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/ProcessMaker/Octane/ResetRequestStateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Illuminate\Support\Facades\Event;
use Laravel\Octane\Events\RequestTerminated;
use ProcessMaker\Events\RedirectToEvent;
use ProcessMaker\ImportExport\Manifest;
use ProcessMaker\ImportExport\Options;
use ProcessMaker\Listeners\HandleRedirectListener;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Octane\ResetRequestState;
Expand All @@ -23,6 +25,7 @@ class ResetRequestStateTest extends TestCase
protected function tearDown(): void
{
ProcessMakerServiceProvider::beginRequestTiming();
Manifest::resetRequestState();

parent::tearDown();
}
Expand All @@ -34,6 +37,30 @@ private function recordQueryDuration(float $milliseconds): void
event(new QueryExecuted('SELECT 1', [], $milliseconds, $connection));
}

public function test_octane_request_termination_resets_manifest_request_state(): void
{
Manifest::buildParentModeMap([
'parent-uuid' => [
'dependents' => [
['uuid' => 'child-uuid'],
],
],
], new Options([
'parent-uuid' => ['mode' => 'update'],
]));

$this->assertNotNull(Manifest::$parents);

event(new RequestTerminated(
$this->app,
$this->app,
Request::create('/import-request'),
new Response()
));

$this->assertNull(Manifest::$parents);
}

public function test_it_clears_request_timing_before_the_next_request(): void
{
DB::select('SELECT 1');
Expand Down
Loading