Skip to content

Commit dfbf6cd

Browse files
alongoszadamwojsViniTou
authored
IBX-8471: Upgraded codebase to Symfony 7 (#87)
* [Composer] Dropped obsolete symfony/proxy-manager-bridge * [Composer] Bumped Symfony packages requirements to ^7.2 * [Composer] Bumped 3rd party packages compatible with for Symfony 7 * Added missing Ibexa\Solr\Indexer::$searchHandler type declaration * [symfony/dependency-injection] Remove usage of deprecated ContainerAwareTrait * [Tests] Added missing type declaration to Ibexa\Tests\Solr\SetupFactory\LegacySetupFactory::getRepository * [doctrine/dbal] Fixed usage of deprecated Doctrine\DBAL\Query\QueryBuilder::execute method * [CS] Fixed code style issues * [Tests] Configured SYMFONY_DEPRECATIONS_HELPER env variable * [PHPStan] Regenerated phpstan baseline --------- Co-authored-by: Adam Wójs <[email protected]> Co-authored-by: Dawid Parafiński <[email protected]>
1 parent 37b4ba1 commit dfbf6cd

File tree

9 files changed

+28
-47
lines changed

9 files changed

+28
-47
lines changed

composer.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@
1818
"ext-xmlwriter": "*",
1919
"ibexa/core": "~5.0.x-dev",
2020
"netgen/query-translator": "^1.0.2",
21-
"symfony/http-kernel": "^6.4",
22-
"symfony/dependency-injection": "^6.4",
23-
"symfony/console": "^6.4",
24-
"symfony/config": "^6.4",
25-
"symfony/framework-bundle": "^6.4",
26-
"symfony/http-client": "^6.4"
21+
"symfony/config": "^7.2",
22+
"symfony/console": "^7.2",
23+
"symfony/dependency-injection": "^7.2",
24+
"symfony/framework-bundle": "^7.2",
25+
"symfony/http-client": "^7.2",
26+
"symfony/http-kernel": "^7.2"
2727
},
2828
"require-dev": {
2929
"ibexa/code-style": "~2.0.0",
3030
"ibexa/doctrine-schema": "~5.0.x-dev",
3131
"ibexa/rector": "~5.0.x-dev",
32-
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
32+
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
3333
"phpstan/phpstan": "^2.0",
3434
"phpstan/phpstan-phpunit": "^2.0",
3535
"phpstan/phpstan-symfony": "^2.0",
3636
"phpunit/phpunit": "^9.6",
37-
"symfony/phpunit-bridge": "^6.4",
38-
"symfony/proxy-manager-bridge": "^6.4"
37+
"symfony/phpunit-bridge": "^7.2"
3938
},
4039
"autoload": {
4140
"psr-4": {

phpstan.neon.dist

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ includes:
44
- phpstan-baseline.neon
55

66
parameters:
7-
ignoreErrors:
8-
-
9-
message: "#^Cannot call method (fetchOne|fetchAll|fetchAllAssociative|fetchAssociative|fetchAllKeyValue)\\(\\) on Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string\\.$#"
10-
paths:
11-
- tests/*
127
level: 8
138
paths:
149
- src

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
convertWarningsToExceptions="true">
77
<php>
88
<ini name="error_reporting" value="-1" />
9+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[indirect]=92"/>
910
</php>
1011
<testsuites>
1112
<testsuite name="Solr search engine tests">

src/bundle/ApiLoader/BoostFactorProviderFactory.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@
88
namespace Ibexa\Bundle\Solr\ApiLoader;
99

1010
use Ibexa\Contracts\Core\Container\ApiLoader\RepositoryConfigurationProviderInterface;
11-
use Ibexa\Solr\FieldMapper\BoostFactorProvider;
12-
use LogicException;
13-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
14-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
11+
use Symfony\Component\DependencyInjection\ContainerInterface;
1512

1613
/**
1714
* BoostFactorProvider service factory takes into account boost factor semantic configuration.
1815
*/
19-
class BoostFactorProviderFactory implements ContainerAwareInterface
16+
class BoostFactorProviderFactory
2017
{
21-
use ContainerAwareTrait;
18+
private ContainerInterface $container;
2219

2320
private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider;
2421

@@ -37,21 +34,19 @@ class BoostFactorProviderFactory implements ContainerAwareInterface
3734
* @param string $boostFactorProviderClass
3835
*/
3936
public function __construct(
37+
ContainerInterface $container,
4038
RepositoryConfigurationProviderInterface $repositoryConfigurationProvider,
4139
$defaultConnection,
4240
$boostFactorProviderClass
4341
) {
42+
$this->container = $container;
4443
$this->repositoryConfigurationProvider = $repositoryConfigurationProvider;
4544
$this->defaultConnection = $defaultConnection;
4645
$this->boostFactorProviderClass = $boostFactorProviderClass;
4746
}
4847

4948
public function buildService()
5049
{
51-
if ($this->container === null) {
52-
throw new LogicException(sprintf('Unable to build %s due to missing container reference', BoostFactorProvider::class));
53-
}
54-
5550
$repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
5651

5752
$connection = $this->defaultConnection;

src/bundle/ApiLoader/IndexingDepthProviderFactory.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
namespace Ibexa\Bundle\Solr\ApiLoader;
1010

1111
use Ibexa\Contracts\Core\Container\ApiLoader\RepositoryConfigurationProviderInterface;
12-
use Ibexa\Solr\FieldMapper\IndexingDepthProvider;
13-
use LogicException;
14-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
15-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
12+
use Symfony\Component\DependencyInjection\ContainerInterface;
1613

17-
class IndexingDepthProviderFactory implements ContainerAwareInterface
14+
class IndexingDepthProviderFactory
1815
{
19-
use ContainerAwareTrait;
16+
private ContainerInterface $container;
2017

2118
private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider;
2219

@@ -25,21 +22,19 @@ class IndexingDepthProviderFactory implements ContainerAwareInterface
2522
private string $indexingDepthProviderClass;
2623

2724
public function __construct(
25+
ContainerInterface $container,
2826
RepositoryConfigurationProviderInterface $repositoryConfigurationProvider,
2927
string $defaultConnection,
3028
string $indexingDepthProviderClass
3129
) {
30+
$this->container = $container;
3231
$this->repositoryConfigurationProvider = $repositoryConfigurationProvider;
3332
$this->defaultConnection = $defaultConnection;
3433
$this->indexingDepthProviderClass = $indexingDepthProviderClass;
3534
}
3635

3736
public function buildService()
3837
{
39-
if ($this->container === null) {
40-
throw new LogicException(sprintf('Unable to build %s due to missing container reference', IndexingDepthProvider::class));
41-
}
42-
4338
$repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
4439

4540
$connection = $this->defaultConnection;

src/bundle/IbexaSolrBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ public function getContainerExtension(): ?ExtensionInterface
4242
$this->extension = new IbexaSolrExtension();
4343
}
4444

45-
return $this->extension;
45+
return $this->extension ?: null;
4646
}
4747
}

src/bundle/Resources/config/services.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,17 @@ services:
4444

4545
Ibexa\Bundle\Solr\ApiLoader\BoostFactorProviderFactory:
4646
arguments:
47+
- '@service_container'
4748
- '@Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider'
4849
- "%ibexa.solr.default_connection%"
49-
- Ibexa\Solr\FieldMapper\BoostFactorProvider
50-
calls:
51-
- [setContainer, ["@service_container"]]
50+
- 'Ibexa\Solr\FieldMapper\BoostFactorProvider'
5251

5352
Ibexa\Bundle\Solr\ApiLoader\IndexingDepthProviderFactory:
5453
arguments:
54+
- '@service_container'
5555
- '@Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider'
5656
- "%ibexa.solr.default_connection%"
5757
- Ibexa\Solr\FieldMapper\IndexingDepthProvider
58-
calls:
59-
- [setContainer, ["@service_container"]]
6058

6159
Ibexa\Solr\FieldMapper\IndexingDepthProvider:
6260
class: Ibexa\Solr\FieldMapper\IndexingDepthProvider

src/lib/Indexer.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@
1212
use Ibexa\Contracts\Core\Persistence\Content\ContentInfo;
1313
use Ibexa\Contracts\Core\Persistence\Handler as PersistenceHandler;
1414
use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException;
15+
use Ibexa\Contracts\Core\Search\Handler as SearchHandler;
1516
use Ibexa\Core\Search\Common\IncrementalIndexer;
1617
use Ibexa\Solr\Handler as SolrSearchHandler;
1718
use Psr\Log\LoggerInterface;
1819

1920
class Indexer extends IncrementalIndexer
2021
{
21-
/**
22-
* @var \Ibexa\Solr\Handler
23-
*/
24-
protected $searchHandler;
22+
protected SearchHandler $searchHandler;
2523

2624
public function __construct(
2725
LoggerInterface $logger,

tests/lib/SetupFactory/LegacySetupFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
namespace Ibexa\Tests\Solr\SetupFactory;
99

1010
use Doctrine\DBAL\Connection;
11-
use Doctrine\DBAL\FetchMode;
1211
use Ibexa\Bundle\Solr\DependencyInjection\IbexaSolrExtension;
1312
use Ibexa\Contracts\Core\Persistence\Content\Handler;
13+
use Ibexa\Contracts\Core\Repository\Repository;
1414
use Ibexa\Contracts\Core\Test\Repository\SetupFactory\Legacy as CoreLegacySetupFactory;
1515
use Ibexa\Core\Base\Container\Compiler\Search\AggregateFieldValueMapperPass;
1616
use Ibexa\Core\Base\Container\Compiler\Search\FieldRegistryPass;
@@ -49,7 +49,7 @@ public function __construct()
4949
*
5050
* @return \Ibexa\Contracts\Core\Repository\Repository
5151
*/
52-
public function getRepository($initializeFromScratch = true)
52+
public function getRepository($initializeFromScratch = true): Repository
5353
{
5454
// Load repository first so all initialization steps are done
5555
$repository = parent::getRepository($initializeFromScratch);
@@ -133,7 +133,7 @@ protected function indexAll(): void
133133
->select('id')
134134
->from(ContentGateway::CONTENT_ITEM_TABLE);
135135

136-
$contentIds = array_map('intval', $query->execute()->fetchAll(FetchMode::COLUMN));
136+
$contentIds = array_map('intval', $query->executeQuery()->fetchFirstColumn());
137137

138138
$contentItems = $contentHandler->loadContentList($contentIds);
139139

0 commit comments

Comments
 (0)