From d0c7120efd8e2c89b96d59f1640045839186faba Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Fri, 5 Jun 2026 13:45:34 +0200 Subject: [PATCH 1/4] IBX-11848: ibexa:reindex --content-type will only index content available for anonymous --- .../ContentTypeInputGeneratorStrategy.php | 13 +++++++++++-- src/bundle/Core/Command/ReindexCommand.php | 2 +- .../ContentTypeInputGeneratorStrategyTest.php | 13 ++++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) 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, From a32001f6341550c1bc170691fb21f7d3fca0d8ff Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Fri, 19 Jun 2026 13:14:45 +0200 Subject: [PATCH 2/4] fixup! IBX-11848: ibexa:reindex --content-type will only index content available for anonymous --- src/bundle/Core/Command/ReindexCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundle/Core/Command/ReindexCommand.php b/src/bundle/Core/Command/ReindexCommand.php index 24aef23381..8019eded23 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; From ab30bb7b43197db17382729208e92ece982f843c Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Fri, 19 Jun 2026 14:40:39 +0200 Subject: [PATCH 3/4] Fixed PHPStan --- phpstan-baseline.neon | 2 +- .../Core/Repository/FieldType/DateAndTimeIntegrationTest.php | 2 -- .../Core/Repository/FieldType/DateIntegrationTest.php | 2 -- .../Core/Repository/FieldType/RelationIntegrationTest.php | 2 -- .../Core/Repository/FieldType/RelationListIntegrationTest.php | 2 -- .../Core/Repository/FieldType/SelectionIntegrationTest.php | 2 -- .../Core/Repository/FieldType/TimeIntegrationTest.php | 2 -- .../Symfony/Component/Serializer/HostElementNormalizerTest.php | 1 + tests/lib/Repository/Service/Mock/ContentTest.php | 1 + tests/lib/Repository/Service/Mock/UrlAliasTest.php | 1 + 10 files changed, 4 insertions(+), 13 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 4adced4037..8425c66ed4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -31239,7 +31239,7 @@ parameters: - message: '#^Offset ''scheme'' might not exist on array\{scheme\?\: string, host\: string, port\: int\<0, 65535\>, user\?\: string, pass\?\: string, path\?\: string, query\?\: string, fragment\?\: string\}\.$#' identifier: offsetAccess.notFound - count: 4 + count: 2 path: tests/bundle/Core/Routing/DefaultRouterTest.php - diff --git a/tests/integration/Core/Repository/FieldType/DateAndTimeIntegrationTest.php b/tests/integration/Core/Repository/FieldType/DateAndTimeIntegrationTest.php index 8b733ee841..6ad753cb01 100644 --- a/tests/integration/Core/Repository/FieldType/DateAndTimeIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/DateAndTimeIntegrationTest.php @@ -35,8 +35,6 @@ public function getTypeName() */ protected function supportsLikeWildcard($value) { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/DateIntegrationTest.php b/tests/integration/Core/Repository/FieldType/DateIntegrationTest.php index 2fc2508f44..0d0fd35adf 100644 --- a/tests/integration/Core/Repository/FieldType/DateIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/DateIntegrationTest.php @@ -36,8 +36,6 @@ public function getTypeName() */ protected function supportsLikeWildcard($value) { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/RelationIntegrationTest.php b/tests/integration/Core/Repository/FieldType/RelationIntegrationTest.php index a47546c4a7..fbb6dd252c 100644 --- a/tests/integration/Core/Repository/FieldType/RelationIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/RelationIntegrationTest.php @@ -38,8 +38,6 @@ public function getTypeName() */ protected function supportsLikeWildcard($value) { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/RelationListIntegrationTest.php b/tests/integration/Core/Repository/FieldType/RelationListIntegrationTest.php index 6f9f861d1b..e57596e986 100644 --- a/tests/integration/Core/Repository/FieldType/RelationListIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/RelationListIntegrationTest.php @@ -38,8 +38,6 @@ public function getTypeName() */ protected function supportsLikeWildcard($value) { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/SelectionIntegrationTest.php b/tests/integration/Core/Repository/FieldType/SelectionIntegrationTest.php index a8395a6f0b..32e111d149 100644 --- a/tests/integration/Core/Repository/FieldType/SelectionIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/SelectionIntegrationTest.php @@ -36,8 +36,6 @@ public function getTypeName() */ protected function supportsLikeWildcard($value) { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/integration/Core/Repository/FieldType/TimeIntegrationTest.php b/tests/integration/Core/Repository/FieldType/TimeIntegrationTest.php index 87132350bf..033167eadf 100644 --- a/tests/integration/Core/Repository/FieldType/TimeIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/TimeIntegrationTest.php @@ -34,8 +34,6 @@ public function getTypeName() */ protected function supportsLikeWildcard($value) { - parent::supportsLikeWildcard($value); - return false; } diff --git a/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php b/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php index e409df5a27..e89024a7de 100644 --- a/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php +++ b/tests/lib/MVC/Symfony/Component/Serializer/HostElementNormalizerTest.php @@ -25,6 +25,7 @@ public function testNormalization(): void $matcher = new HostElement(2); // Set request and invoke match to initialize HostElement::$hostElements $matcher->setRequest(SimplifiedRequest::fromUrl('http://ibexa.dev/foo/bar')); + // @phpstan-ignore method.resultUnused $matcher->match(); $this->assertEquals( diff --git a/tests/lib/Repository/Service/Mock/ContentTest.php b/tests/lib/Repository/Service/Mock/ContentTest.php index 339d23b203..485ee5c0a2 100644 --- a/tests/lib/Repository/Service/Mock/ContentTest.php +++ b/tests/lib/Repository/Service/Mock/ContentTest.php @@ -89,6 +89,7 @@ public function testConstructor(): void 'remove_archived_versions_on_publish' => true, ]; + // @phpstan-ignore new.resultUnused new ContentService( $repositoryMock, $persistenceHandlerMock, diff --git a/tests/lib/Repository/Service/Mock/UrlAliasTest.php b/tests/lib/Repository/Service/Mock/UrlAliasTest.php index cb06533ddb..27a891c191 100644 --- a/tests/lib/Repository/Service/Mock/UrlAliasTest.php +++ b/tests/lib/Repository/Service/Mock/UrlAliasTest.php @@ -54,6 +54,7 @@ public function testConstructor() { $repositoryMock = $this->getRepositoryMock(); + // @phpstan-ignore new.resultUnused new UrlALiasService( $repositoryMock, $this->urlAliasHandler, From ae866dc9856b923ec6c49e6d579d5d5018dbc5b2 Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Fri, 19 Jun 2026 15:16:04 +0200 Subject: [PATCH 4/4] fixup! Fixed PHPStan --- phpstan-baseline-lte-8.3.neon | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phpstan-baseline-lte-8.3.neon b/phpstan-baseline-lte-8.3.neon index ab58eb7013..1ac105db1c 100644 --- a/phpstan-baseline-lte-8.3.neon +++ b/phpstan-baseline-lte-8.3.neon @@ -1,11 +1,5 @@ parameters: ignoreErrors: - - - message: '#^Call to new Ibexa\\Core\\Repository\\URLAliasService\(\) on a separate line has no effect\.$#' - identifier: new.resultUnused - count: 1 - path: tests/lib/Repository/Service/Mock/UrlAliasTest.php - - message: '#^Dead catch \- Ibexa\\Contracts\\Core\\Repository\\Exceptions\\NotFoundException is never thrown in the try block\.$#' identifier: catch.neverThrown