Skip to content

Commit 010fbc0

Browse files
Fix backward compatibility for doctrine (acseo#82)
* keep compatibility with Doctrine 2.x.x (acseo#78) * fix composer to allow tests to pass --------- Co-authored-by: Lucas Ferraro <lucasferraro@users.noreply.github.com>
1 parent 9cc51e6 commit 010fbc0

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

composer.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
"require": {
1313
"php": "^7.4||^8.0",
1414
"doctrine/orm": "~2.8,>=2.8.0",
15-
"symfony/framework-bundle": "^3.4|^4.3|^5|^6.0",
16-
"symfony/http-client-contracts": "^1.0|^2.0|^3.0",
15+
"symfony/framework-bundle": "^4.3|^5|^6.0",
16+
"symfony/console": "^4.3.4|^5|^6.0",
1717
"typesense/typesense-php": "^4.1.0",
1818
"php-http/curl-client": "^2.2",
1919
"monolog/monolog": "^2.3|^3.0",
20-
"symfony/property-access": "^3.4|^4.3|^5|^6.0"
20+
"symfony/property-access": "^3.4|^4.3|^5|^6.0",
21+
"symfony/http-client": "^5.4|^6.2"
2122
},
2223
"require-dev": {
2324
"symfony/phpunit-bridge": "^5.0|^6.0",
@@ -39,5 +40,10 @@
3940
"Composer\\Config::disableProcessTimeout",
4041
"docker run -i -p 8108:8108 -v/tmp/typesense-server-data-1c/:/data typesense/typesense:0.23.0 --data-dir /data --api-key=123 --listen-port 8108 --enable-cors"
4142
]
43+
},
44+
"config": {
45+
"allow-plugins": {
46+
"php-http/discovery": true
47+
}
4248
}
4349
}

src/Command/ImportCommand.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6767

6868
$action = $input->getOption('action');
6969

70-
$this->em->getConnection()->getConfiguration()->setMiddlewares(
71-
[new \Doctrine\DBAL\Logging\Middleware(new \Psr\Log\NullLogger())]
72-
);
73-
70+
// 'setMiddlewares' method only exists for Doctrine version >=3.0.0
71+
if (method_exists($this->em->getConnection()->getConfiguration(), 'setMiddlewares')) {
72+
$this->em->getConnection()->getConfiguration()->setMiddlewares(
73+
[new \Doctrine\DBAL\Logging\Middleware(new \Psr\Log\NullLogger())]
74+
);
75+
} else {
76+
// keep compatibility with versions 2.x.x of Doctrine
77+
$this->em->getConnection()->getConfiguration()->setSQLLogger(null);
78+
}
79+
7480
$execStart = microtime(true);
7581
$populated = 0;
7682

0 commit comments

Comments
 (0)