From ae2a94e66f266b5b46eb863ccdcd57af5fdf3f4c Mon Sep 17 00:00:00 2001 From: Nolan Ehrstrom Date: Wed, 8 Oct 2025 09:39:15 -0700 Subject: [PATCH] Fix error when dependent screen is missing --- .../ImportExport/Exporters/ScreenExporter.php | 5 ++-- .../Exporters/ScreenExporterTest.php | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ProcessMaker/ImportExport/Exporters/ScreenExporter.php b/ProcessMaker/ImportExport/Exporters/ScreenExporter.php index 03370ed26d..119803feae 100644 --- a/ProcessMaker/ImportExport/Exporters/ScreenExporter.php +++ b/ProcessMaker/ImportExport/Exporters/ScreenExporter.php @@ -97,11 +97,12 @@ private function getNestedScreens() : array $screenFinder = new ScreensInScreen(); foreach ($screenFinder->referencesToExport($this->model, [], null, false) as $screen) { try { - $screen = Screen::find($screen[1]); + $screenId = $screen[1]; + $screen = Screen::find($screenId); if ($screen) { $screens[] = $screen; } else { - \Log::debug("NestedScreen screenId: $screen[1] not exists"); + \Log::debug("NestedScreen screenId: $screenId not exists"); } } catch (ModelNotFoundException $error) { \Log::error($error->getMessage()); diff --git a/tests/Feature/ImportExport/Exporters/ScreenExporterTest.php b/tests/Feature/ImportExport/Exporters/ScreenExporterTest.php index c34a8c42b5..899145b98c 100644 --- a/tests/Feature/ImportExport/Exporters/ScreenExporterTest.php +++ b/tests/Feature/ImportExport/Exporters/ScreenExporterTest.php @@ -330,4 +330,28 @@ public function testAttemptToAddMultipleInterstials() $newInterstitial = Screen::where('title', 'Default Interstitial 2')->firstOrFail(); $this->assertNull($newInterstitial->key); } + + public function testExportScreenWithMissingDependentScreen() + { + $screen = Screen::factory()->create([ + 'title' => 'Screen with missing dependent screen', + 'key' => 'screen', + 'config' => [ + ['items' => [ + ['component' => 'FormNestedScreen', 'config' => ['screen' => 9999999999]], + ]], + ], + ]); + + $exporter = new Exporter(); + $exporter->exportScreen($screen); + $payload = $exporter->payload(); + + $screens = Arr::where($payload['export'], function ($value) { + return $value['type'] === 'Screen'; + }); + + $this->assertCount(1, $screens); + $this->assertEquals($screen->uuid, Arr::first($screens)['attributes']['uuid']); + } }