Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9306,12 +9306,6 @@ parameters:
count: 1
path: src/lib/Base/Container/Compiler/Search/FieldRegistryPass.php

-
message: '#^Method Ibexa\\Core\\Base\\Container\\Compiler\\Search\\Legacy\\CriteriaConverterPass\:\:process\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: src/lib/Base/Container/Compiler/Search/Legacy/CriteriaConverterPass.php

-
message: '#^Method Ibexa\\Core\\Base\\Container\\Compiler\\Search\\Legacy\\CriterionFieldValueHandlerRegistryPass\:\:process\(\) has no return type specified\.$#'
identifier: missingType.return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace Ibexa\Bundle\LegacySearchEngine;

use Ibexa\Core\Base\Container\Compiler\Search\FieldRegistryPass;
use Ibexa\Core\Base\Container\Compiler\Search\Legacy\CriteriaConverterPass;
use Ibexa\Core\Base\Container\Compiler\Search\Legacy\CriterionFieldValueHandlerRegistryPass;
use Ibexa\Core\Base\Container\Compiler\Search\Legacy\SortClauseConverterPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -19,7 +18,6 @@ public function build(ContainerBuilder $container)
{
parent::build($container);

$container->addCompilerPass(new CriteriaConverterPass());
$container->addCompilerPass(new CriterionFieldValueHandlerRegistryPass());
$container->addCompilerPass(new SortClauseConverterPass());
$container->addCompilerPass(new FieldRegistryPass());
Expand Down

This file was deleted.

25 changes: 18 additions & 7 deletions src/lib/Persistence/Legacy/URL/Query/CriteriaConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,44 @@
use Doctrine\DBAL\Query\QueryBuilder;
use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException;
use Ibexa\Contracts\Core\Repository\Values\URL\Query\Criterion;
use Traversable;

class CriteriaConverter
{
/**
* Criterion handlers.
*
* @var \Ibexa\Core\Persistence\Legacy\URL\Query\CriterionHandler[]
* @var iterable<\Ibexa\Core\Persistence\Legacy\URL\Query\CriterionHandler>
*/
protected $handlers;
protected iterable $handlers;

/**
* Construct from an optional array of Criterion handlers.
*
* @param \Ibexa\Core\Persistence\Legacy\URL\Query\CriterionHandler[] $handlers
* @param iterable<\Ibexa\Core\Persistence\Legacy\URL\Query\CriterionHandler> $handlers
*/
public function __construct(array $handlers = [])
public function __construct(iterable $handlers = [])
{
$this->handlers = $handlers;
}

/**
* Adds handler.
*
* @param \Ibexa\Core\Persistence\Legacy\URL\Query\CriterionHandler $handler
* @deprecated The "%s" method is deprecated. Use a service definition tag "ibexa.storage.legacy.url.criterion.handler" instead.
*/
public function addHandler(CriterionHandler $handler)
{
trigger_deprecation(
'ibexa/core',
'4.6.24',
'The "%s" method is deprecated. Use a service definition tag ("%s") instead.',
__METHOD__,
'ibexa.storage.legacy.url.criterion.handler',
);

if ($this->handlers instanceof Traversable) {
$this->handlers = iterator_to_array($this->handlers);
}
Comment on lines +46 to +48
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting a Traversable to array using iterator_to_array() may cause performance issues if the iterator is large or expensive to iterate. Consider checking if this conversion is necessary or if the code can work with the iterator directly.

Copilot uses AI. Check for mistakes.


$this->handlers[] = $handler;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
services:
# Note: services tagged with:
# - ibexa.search.legacy.gateway.criterion_handler.content
# are registered to this one using compilation pass
ibexa.search.legacy.gateway.criteria_converter.content:
class: Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter
lazy: true
arguments:
$handlers: !tagged_iterator ibexa.search.legacy.gateway.criterion_handler.content

Ibexa\Core\Search\Legacy\Content\Gateway\CriterionHandler\Ancestor:
parent: Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
services:
# Note: services tagged with:
# - ibexa.search.legacy.gateway.criterion_handler.location
# are registered to this one using compilation pass
ibexa.search.legacy.gateway.criteria_converter.location:
class: Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter
lazy: true
arguments:
$handlers: !tagged_iterator ibexa.search.legacy.gateway.criterion_handler.location

Ibexa\Core\Search\Legacy\Content\Location\Gateway\CriterionHandler\Ancestor:
parent: Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler
Expand Down
2 changes: 2 additions & 0 deletions src/lib/Resources/settings/storage_engines/legacy/trash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
ibexa.core.trash.search.legacy.gateway.criteria_converter:
class: Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter
lazy: true
arguments:
$handlers: !tagged_iterator ibexa.search.legacy.trash.gateway.criterion.handler

ibexa.core.trash.search.legacy.gateway.sort_clause_converter:
class: Ibexa\Core\Search\Legacy\Content\Common\Gateway\SortClauseConverter
Expand Down
2 changes: 2 additions & 0 deletions src/lib/Resources/settings/storage_engines/legacy/url.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ services:
Ibexa\Core\Persistence\Legacy\URL\Query\CriteriaConverter:
class: Ibexa\Core\Persistence\Legacy\URL\Query\CriteriaConverter
lazy: true
arguments:
$handlers: !tagged_iterator ibexa.storage.legacy.url.criterion.handler
27 changes: 22 additions & 5 deletions src/lib/Search/Legacy/Content/Common/Gateway/CriteriaConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\DBAL\Query\QueryBuilder;
use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException;
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
use Traversable;

/**
* Content locator gateway implementation using the DoctrineDatabase.
Expand All @@ -20,25 +21,41 @@ class CriteriaConverter
*
* @var \Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler[]
*/
protected $handlers;
protected iterable $handlers;

/**
* Construct from an optional array of Criterion handlers.
*
* @param \Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler[] $handlers
*/
public function __construct(array $handlers = [])
public function __construct(iterable $handlers = [])
{
$this->handlers = $handlers;
}

/**
* Adds handler.
*
* @param \Ibexa\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler $handler
* @deprecated The "%s" method is deprecated. Use a service definition tag instead (one of
* "ibexa.search.legacy.gateway.criterion_handler.content",
* "ibexa.search.legacy.gateway.criterion_handler.location",
* "ibexa.search.legacy.trash.gateway.criterion.handler").
*/
public function addHandler(CriterionHandler $handler)
{
trigger_deprecation(
'ibexa/core',
'4.6.24',
'The "%s" method is deprecated. Use a service definition tag instead (one of "%s").',
__METHOD__,
implode('", "', [
'ibexa.search.legacy.gateway.criterion_handler.content',
'ibexa.search.legacy.gateway.criterion_handler.location',
'ibexa.search.legacy.trash.gateway.criterion.handler',
]),
);

if ($this->handlers instanceof Traversable) {
$this->handlers = iterator_to_array($this->handlers);
}
Comment on lines +56 to +58
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting a Traversable to array using iterator_to_array() may cause performance issues if the iterator is large or expensive to iterate. Consider checking if this conversion is necessary or if the code can work with the iterator directly.

Copilot uses AI. Check for mistakes.

$this->handlers[] = $handler;
}

Expand Down
1 change: 0 additions & 1 deletion tests/integration/Core/LegacyTestContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ private function registerCompilerPasses(): void
$this->addCompilerPass(new Compiler\Storage\Legacy\FieldValueConverterRegistryPass());
$this->addCompilerPass(new Compiler\Storage\Legacy\RoleLimitationConverterPass());

$this->addCompilerPass(new Compiler\Search\Legacy\CriteriaConverterPass());
$this->addCompilerPass(new Compiler\Search\Legacy\CriterionFieldValueHandlerRegistryPass());
$this->addCompilerPass(new Compiler\Search\Legacy\SortClauseConverterPass());

Expand Down
Loading
Loading