diff --git a/src/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategy.php b/src/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategy.php index 8b6faa8ccf..93bcaec5ab 100644 --- a/src/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategy.php +++ b/src/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategy.php @@ -11,6 +11,7 @@ use Generator; use Ibexa\Bundle\Core\Command\Indexer\ContentIdListGeneratorStrategyInterface; use Ibexa\Contracts\Core\Repository\ContentService; +use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\Content\ContentList; use Ibexa\Contracts\Core\Repository\Values\Content\Query; use Ibexa\Contracts\Core\Repository\Values\Filter\Filter; @@ -24,9 +25,12 @@ final class ContentTypeInputGeneratorStrategy implements ContentIdListGeneratorS { private ContentService $contentService; - public function __construct(ContentService $contentService) + private Repository $repository; + + public function __construct(ContentService $contentService, Repository $repository) { $this->contentService = $contentService; + $this->repository = $repository; } /** @@ -74,6 +78,11 @@ private function getContentList(string $contentTypeIdentifier): ContentList ) ; - return $this->contentService->find($filter); + /** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentList $contentList */ + $contentList = $this->repository->sudo(function () use ($filter) { + return $this->contentService->find($filter); + }); + + return $contentList; } } diff --git a/src/bundle/Core/Command/ReindexCommand.php b/src/bundle/Core/Command/ReindexCommand.php index 8019eded23..24aef23381 100644 --- a/src/bundle/Core/Command/ReindexCommand.php +++ b/src/bundle/Core/Command/ReindexCommand.php @@ -70,7 +70,7 @@ public function __construct( bool $isDebug, string $projectDir, ContentIdListGeneratorStrategyInterface $contentIdListGeneratorStrategy, - ?string $phpPath = null + ?string $phpPath = null, ) { $this->gateway = $gateway; $this->searchIndexer = $searchIndexer; diff --git a/tests/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategyTest.php b/tests/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategyTest.php index 573243ba1d..9bb6c7a39f 100644 --- a/tests/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategyTest.php +++ b/tests/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategyTest.php @@ -10,6 +10,7 @@ use Ibexa\Bundle\Core\Command\Indexer\ContentIdList\ContentTypeInputGeneratorStrategy; use Ibexa\Contracts\Core\Repository\ContentService; +use Ibexa\Contracts\Core\Repository\Repository; use Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo; use Ibexa\Contracts\Core\Repository\Values\Content\ContentList; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; @@ -32,10 +33,20 @@ public function testGetGenerator(ContentList $contentList, int $batchSize, array $contentServiceMock = $this->createMock(ContentService::class); $contentServiceMock->method('find')->willReturn($contentList); + $repositoryMock = $this->createMock(Repository::class); + $repositoryMock + ->method('sudo') + ->willReturnCallback( + static fn (callable $callback) => $callback() + ); + $inputMock = $this->createMock(InputInterface::class); $inputMock->method('getOption')->with('content-type')->willReturn(uniqid('type', true)); - $strategy = new ContentTypeInputGeneratorStrategy($contentServiceMock); + $strategy = new ContentTypeInputGeneratorStrategy( + $contentServiceMock, + $repositoryMock + ); self::assertSame( $expectedBatches,