diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8425c66ed4..cfc986e841 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -9349,7 +9349,7 @@ parameters: path: src/lib/Base/Exceptions/ContentFieldValidationException.php - - message: '#^PHPDoc tag @var with type callable\(Ibexa\\Contracts\\Core\\Repository\\Values\\Translation\|string\)\: string is not subtype of native type Closure\(mixed\)\: string\.$#' + message: '#^PHPDoc tag @var with type callable\(Ibexa\\Contracts\\Core\\Repository\\Values\\Translation\|string\)\: string is not subtype of native type static\-Closure\(mixed\)\: string\.$#' identifier: varTag.nativeType count: 1 path: src/lib/Base/Exceptions/ContentFieldValidationException.php diff --git a/src/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategy.php b/src/bundle/Core/Command/Indexer/ContentIdList/ContentTypeInputGeneratorStrategy.php index 8b6faa8ccf..77f6ebe94c 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,8 @@ private function getContentList(string $contentTypeIdentifier): ContentList ) ; - return $this->contentService->find($filter); + return $this->repository->sudo( + fn (): ContentList => $this->contentService->find($filter) + ); } } 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,