Skip to content

Commit

Permalink
Drop support of doctrine/dbal 2
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Nov 24, 2023
1 parent 22b99bf commit 819f35b
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 400 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

jobs:
phpunit:
name: "PHPUnit ${{ matrix.php-version }} (${{ matrix.deps }})${{ matrix.dbal-version && format(' - DBAL {0}', matrix.dbal-version) || '' }}"
name: "PHPUnit ${{ matrix.php-version }} (${{ matrix.deps }})"
runs-on: "ubuntu-20.04"

services:
Expand All @@ -29,17 +29,9 @@ jobs:
- "8.2"
deps:
- "highest"
dbal-version:
- ""
include:
- deps: "lowest"
php-version: "7.4"
- deps: "highest"
php-version: "8.2"
dbal-version: "^2.13.1"
- deps: "highest"
php-version: "8.2"
dbal-version: "^3.2"
- deps: "highest"
php-version: "8.1"

Expand All @@ -56,10 +48,6 @@ jobs:
extensions: mongodb
coverage: "pcov"

- name: "Restrict DBAL version"
if: "${{ matrix.dbal-version }}"
run: "composer require --dev --no-update doctrine/dbal:${{ matrix.dbal-version }}"

# Remove PHP-CS-Fixer to avoid conflicting dependency ranges (i.e. doctrine/annotations)
- name: "Remove PHP-CS-Fixer"
run: "composer remove --dev --no-update friendsofphp/php-cs-fixer"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ a release.
### Changed
- Dropped support for PHP < 7.4
- Dropped support for Symfony < 5.4
- Dropped support for doctrine/dbal < 3.2

### Deprecated
- Calling `Gedmo\Mapping\Event\Adapter\ORM::getObjectManager()` and `getObject()` on EventArgs that do not implement `getObjectManager()` and `getObject()` (such as old EventArgs implementing `getEntityManager()` and `getEntity()`)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"require-dev": {
"doctrine/cache": "^1.11 || ^2.0",
"doctrine/dbal": "^2.13.1 || ^3.2",
"doctrine/dbal": "^3.2",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/mongodb-odm": "^2.3",
"doctrine/orm": "^2.14.0",
Expand All @@ -69,7 +69,7 @@
"symfony/yaml": "^5.4 || ^6.0"
},
"conflict": {
"doctrine/dbal": "<2.13.1 || ^3.0 <3.2",
"doctrine/dbal": "<3.2",
"doctrine/mongodb-odm": "<2.3",
"doctrine/orm": "<2.14.0 || 2.16.0 || 2.16.1",
"sebastian/comparator": "<2.0"
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,3 @@ parameters:
count: 1
path: tests/Gedmo/Tree/RepositoryTest.php

-
message: "#^Variable \\$stack might not be defined\\.$#"
count: 3
path: tests/Gedmo/Tree/TreeObjectHydratorTest.php

7 changes: 0 additions & 7 deletions tests/Gedmo/Sortable/Fixture/CustomerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Driver\PDO\Exception as PDODriverException;
use Doctrine\DBAL\Driver\PDOException as LegacyPDOException;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
Expand Down Expand Up @@ -124,12 +123,6 @@ public function postRemove(): void

$pdoException = new \PDOException('SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails', 23000);

// @todo: This check can be removed when dropping support for doctrine/dbal 2.x.
if (class_exists(LegacyPDOException::class)) {
// @phpstan-ignore-next-line
throw new ForeignKeyConstraintViolationException(sprintf('An exception occurred while deleting the customer type with id %s.', $this->getId()), new LegacyPDOException($pdoException));
}

throw new ForeignKeyConstraintViolationException(PDODriverException::new($pdoException), null);
}
}
Expand Down
29 changes: 3 additions & 26 deletions tests/Gedmo/Tool/BaseTestCaseORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Gedmo\Tests\Tool;

use Doctrine\Common\EventManager;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Logging\Middleware;
use Doctrine\ORM\Configuration;
Expand Down Expand Up @@ -41,8 +40,6 @@ abstract class BaseTestCaseORM extends TestCase
{
protected ?EntityManager $em = null;

protected QueryAnalyzer $queryAnalyzer;

protected QueryLogger $queryLogger;

protected function setUp(): void
Expand Down Expand Up @@ -75,22 +72,6 @@ protected function getDefaultMockSqliteEntityManager(?EventManager $evm = null,
return $this->em = $em;
}

/**
* TODO: Remove this method when dropping support of doctrine/dbal 2.
*
* Starts query statistic log
*
* @throws \RuntimeException
*/
protected function startQueryLog(): void
{
if (null === $this->em) {
throw new \RuntimeException('EntityManager must be initialized.');
}
$this->queryAnalyzer = new QueryAnalyzer($this->em->getConnection()->getDatabasePlatform());
$this->em->getConfiguration()->setSQLLogger($this->queryAnalyzer);
}

/**
* Creates default mapping driver
*/
Expand Down Expand Up @@ -118,13 +99,9 @@ protected function getDefaultConfiguration(): Configuration
$config->setProxyDir(TESTS_TEMP_DIR);
$config->setProxyNamespace('Proxy');
$config->setMetadataDriverImpl($this->getMetadataDriverImplementation());

// TODO: Remove the "if" check when dropping support of doctrine/dbal 2.
if (class_exists(Middleware::class)) {
$config->setMiddlewares([
new Middleware($this->queryLogger),
]);
}
$config->setMiddlewares([
new Middleware($this->queryLogger),
]);

return $config;
}
Expand Down
133 changes: 0 additions & 133 deletions tests/Gedmo/Tool/QueryAnalyzer.php

This file was deleted.

Loading

0 comments on commit 819f35b

Please sign in to comment.