From 67c153d653df8f2b7418b778e9e69d5c7621caed Mon Sep 17 00:00:00 2001 From: Lachlan Turner Date: Fri, 15 Nov 2024 11:31:26 +1030 Subject: [PATCH 1/2] Allow search terms files without content --- src/export/Model/Data/Suggest/SearchTermsFileGenerator.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/export/Model/Data/Suggest/SearchTermsFileGenerator.php b/src/export/Model/Data/Suggest/SearchTermsFileGenerator.php index 0e857cc..4a00da6 100644 --- a/src/export/Model/Data/Suggest/SearchTermsFileGenerator.php +++ b/src/export/Model/Data/Suggest/SearchTermsFileGenerator.php @@ -37,9 +37,6 @@ public function generateFile(string $directory): string { $defaultLocale = $this->generalConfig->getDefaultLocale(); $searchTerms = $this->getSearchTerms(); - if (empty($searchTerms)) { - return ''; - } $filename = $directory . DIRECTORY_SEPARATOR . ($this->isBlacklist ? self::BLACKLIST_FILENAME : self::WHITELIST_FILENAME); From fdf3ef3b9a186070a5417d7b7a6876c5d6ff6a07 Mon Sep 17 00:00:00 2001 From: Lachlan Turner Date: Fri, 15 Nov 2024 11:35:45 +1030 Subject: [PATCH 2/2] Handle empty filenames and zip file --- src/export/Model/GenerateSuggestExport.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/export/Model/GenerateSuggestExport.php b/src/export/Model/GenerateSuggestExport.php index 6fec2f2..3f69a2a 100644 --- a/src/export/Model/GenerateSuggestExport.php +++ b/src/export/Model/GenerateSuggestExport.php @@ -55,7 +55,16 @@ public function execute(): void // create all required files $files = []; foreach ($this->fileGenerators as $fileGenerator) { - $files[] = $fileGenerator->generateFile($directory); + $file = $fileGenerator->generateFile($directory); + if (!empty($file)) { + $files[] = $fileGenerator->generateFile($directory); + } + } + + // only create the zip file and export entity if there are files to include + if (empty($files)) { + $this->logger->info(__METHOD__ . ': No files to export'); + return; } // create zip file