diff --git a/src/Service/Indexer/InternalResourceIndexer.php b/src/Service/Indexer/InternalResourceIndexer.php index bf71a95..cd10ec5 100644 --- a/src/Service/Indexer/InternalResourceIndexer.php +++ b/src/Service/Indexer/InternalResourceIndexer.php @@ -274,7 +274,7 @@ private function indexTranslationSplittedResources( /** * The resources for a language are indexed here. * - * @param ResourceLocation[] $locations + * @param string[] $locations */ private function indexResourcesPerLanguageIndex( string $processId, @@ -335,7 +335,7 @@ private function indexResourcesPerLanguageIndex( * methods accept a chunk with all paths that are to be indexed via a * request. * - * @param ResourceLocation[] $locations + * @param string[] $locations */ private function indexChunks( string $processId, @@ -346,6 +346,7 @@ private function indexChunks( int $length ): int|false { $resourceList = $this->loadResources( + $lang, $locations, $offset, $length @@ -373,10 +374,11 @@ private function indexChunks( } /** - * @param ResourceLocation[] $locations + * @param string[] $locations * @return Resource[]|false */ private function loadResources( + ResourceLanguage $lang, array $locations, int $offset, int $length @@ -391,7 +393,10 @@ private function loadResources( $resourceList = []; for ($i = $offset; $i < $end; $i++) { - $location = $locations[$i]; + $location = ResourceLocation::of( + $locations[$i], + $lang + ); try { $resource = $this->resourceLoader->load($location); $resourceList[] = $resource; diff --git a/src/Service/Indexer/SiteKit/SubDirTranslationSplitter.php b/src/Service/Indexer/SiteKit/SubDirTranslationSplitter.php index 7aa2205..858d4d7 100644 --- a/src/Service/Indexer/SiteKit/SubDirTranslationSplitter.php +++ b/src/Service/Indexer/SiteKit/SubDirTranslationSplitter.php @@ -29,14 +29,15 @@ public function split(array $pathList): TranslationSplitterResult continue; } if ($location->lang === ResourceLanguage::default()) { - $bases[] = $location; + $bases[] = $location->location; continue; } if (!isset($translations[$location->lang->code])) { $translations[$location->lang->code] = []; } - $translations[$location->lang->code][] = $location; + $translations[$location->lang->code][] = $location->location; } + gc_collect_cycles(); return new TranslationSplitterResult($bases, $translations); } diff --git a/src/Service/Indexer/TranslationSplitterResult.php b/src/Service/Indexer/TranslationSplitterResult.php index 7d784a2..a698f45 100644 --- a/src/Service/Indexer/TranslationSplitterResult.php +++ b/src/Service/Indexer/TranslationSplitterResult.php @@ -5,13 +5,12 @@ namespace Atoolo\Search\Service\Indexer; use Atoolo\Resource\ResourceLanguage; -use Atoolo\Resource\ResourceLocation; class TranslationSplitterResult { /** - * @param ResourceLocation[] $bases - * @param array> $translations + * @param string[] $bases + * @param array> $translations */ public function __construct( private readonly array $bases, @@ -34,7 +33,7 @@ public function getLanguages(): array } /** - * @return ResourceLocation[] + * @return string[] */ public function getBases(): array { @@ -42,7 +41,7 @@ public function getBases(): array } /** - * @return ResourceLocation[] + * @return string[] */ public function getTranslations(ResourceLanguage $lang): array { diff --git a/test/Service/Indexer/SiteKit/SubDirTranslationSplitterTest.php b/test/Service/Indexer/SiteKit/SubDirTranslationSplitterTest.php index a50a3d6..d86057d 100644 --- a/test/Service/Indexer/SiteKit/SubDirTranslationSplitterTest.php +++ b/test/Service/Indexer/SiteKit/SubDirTranslationSplitterTest.php @@ -3,7 +3,6 @@ namespace Atoolo\Search\Test\Service\Indexer\SiteKit; use Atoolo\Resource\ResourceLanguage; -use Atoolo\Resource\ResourceLocation; use Atoolo\Search\Service\Indexer\SiteKit\SubDirTranslationSplitter; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; @@ -58,8 +57,8 @@ public function testGetTranlsations(): void $translations = $result->getTranslations($lang); $expected = [ - ResourceLocation::of('/a/b.php', $lang), - ResourceLocation::of('/c/d.php', $lang), + '/a/b.php', + '/c/d.php', ]; $this->assertEquals( @@ -80,7 +79,7 @@ public function testSplitWithLocParameter(): void $translations = $result->getTranslations($lang); $expected = [ - ResourceLocation::of('/a/b.php', $lang) + '/a/b.php', ]; $this->assertEquals(