Loading core/modules/migrate/src/Plugin/migrate/process/Download.php +6 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,12 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $this->httpClient->get($source, $this->configuration['guzzle_options']); } catch (\Exception $e) { // Since the destination file stream was used as the sink for the Guzzle // request, invalid file content from the failed request may be stored in // a newly created file. Clean up the file if it exists since the request // failed. $this->fileSystem->delete($final_destination); throw new MigrateException("{$e->getMessage()} ($source)"); } Loading core/modules/migrate/tests/src/Functional/process/DownloadFunctionalTest.php +5 −1 Original line number Diff line number Diff line Loading @@ -34,13 +34,14 @@ class DownloadFunctionalTest extends BrowserTestBase { */ public function testExceptionThrow(): void { $invalid_url = "{$this->baseUrl}/not-existent-404"; $invalid_uri = "public://first.txt"; $valid_url = "{$this->baseUrl}/core/misc/favicon.ico"; $definition = [ 'source' => [ 'plugin' => 'embedded_data', 'data_rows' => [ ['url' => $invalid_url, 'uri' => 'public://first.txt'], ['url' => $invalid_url, 'uri' => $invalid_uri], ['url' => $valid_url, 'uri' => 'public://second.ico'], ], 'ids' => [ Loading Loading @@ -86,6 +87,9 @@ public function testExceptionThrow(): void { $this->assertStringContainsString($invalid_url, $message->message); $this->assertEquals(MigrationInterface::MESSAGE_ERROR, $message->level); // Check that no file was created for the failed request. $this->assertFileDoesNotExist($invalid_uri); // Check that the second row was migrated successfully. $map_row = $id_map_plugin->getRowBySource(['url' => $valid_url]); $this->assertEquals(MigrateIdMapInterface::STATUS_IMPORTED, $map_row['source_row_status']); Loading Loading
core/modules/migrate/src/Plugin/migrate/process/Download.php +6 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,12 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $this->httpClient->get($source, $this->configuration['guzzle_options']); } catch (\Exception $e) { // Since the destination file stream was used as the sink for the Guzzle // request, invalid file content from the failed request may be stored in // a newly created file. Clean up the file if it exists since the request // failed. $this->fileSystem->delete($final_destination); throw new MigrateException("{$e->getMessage()} ($source)"); } Loading
core/modules/migrate/tests/src/Functional/process/DownloadFunctionalTest.php +5 −1 Original line number Diff line number Diff line Loading @@ -34,13 +34,14 @@ class DownloadFunctionalTest extends BrowserTestBase { */ public function testExceptionThrow(): void { $invalid_url = "{$this->baseUrl}/not-existent-404"; $invalid_uri = "public://first.txt"; $valid_url = "{$this->baseUrl}/core/misc/favicon.ico"; $definition = [ 'source' => [ 'plugin' => 'embedded_data', 'data_rows' => [ ['url' => $invalid_url, 'uri' => 'public://first.txt'], ['url' => $invalid_url, 'uri' => $invalid_uri], ['url' => $valid_url, 'uri' => 'public://second.ico'], ], 'ids' => [ Loading Loading @@ -86,6 +87,9 @@ public function testExceptionThrow(): void { $this->assertStringContainsString($invalid_url, $message->message); $this->assertEquals(MigrationInterface::MESSAGE_ERROR, $message->level); // Check that no file was created for the failed request. $this->assertFileDoesNotExist($invalid_uri); // Check that the second row was migrated successfully. $map_row = $id_map_plugin->getRowBySource(['url' => $valid_url]); $this->assertEquals(MigrateIdMapInterface::STATUS_IMPORTED, $map_row['source_row_status']); Loading