Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] DBAL 3 #541

Merged
merged 19 commits into from
Feb 16, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
os: [ubuntu-latest]
php: ['8.0', '8.1', '8.2']
doctrine: ['2.11', '2.12', '2.13', '2.14']
doctrine: ['2.14']
steps:
- uses: actions/checkout@v3
- name: Setup PHP
Expand Down
32 changes: 32 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Upgrade to 2.0

## Breaking Change: DBAL 3

The most significant change in version 2.0 is using doctrine/dbal 3. You should [review their upgrade guide](https://github.com/doctrine/dbal/blob/bd54f5043eaff656b314037bf285d8b7f1c311b8/UPGRADE.md) in addition to this one.

## Breaking Change: Removed JSON type
If you were still including this line in your custom_types config, it should be removed:

```
'json' => LaravelDoctrine\ORM\Types\Json::class
```

## Breaking Change: Short namespaces

Short namespaces such as `Entities:User` are no longer supported by Doctrine and have been removed.

## Breaking Change: Minimum Doctrine/ORM version to 2.14

This release supports a minimum doctrine/orm version of 2.14 due to a number of deprecations and new features that we are taking advantage of.

## Breaking Change: Removed MasterSlaveConnection

The old MasterSlaveConnection has been supported for backwards compatibility, but has now been removed. You can migrate to the new PrimaryReadReplicaConnection instead.

## Removed: FluentExporter, GenerateEntitiesCommand, GenerateRepositoriesCommand, ConvertMappingCommand

Doctrine is moving away from code generation and we are following suit, as well as reducing our maintenance burden.

## Removed: --flush option from cache clearing commands

`doctrine:clear:metadata:cache`, `doctrine:clear:query:cache`, `doctrine:clear:result:cache` no longer support the flush option due to moving from the obsolete Doctrine cache to the Symfony cache.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
"require": {
"php": "^8.0",
"doctrine/annotations": "^1.13",
"doctrine/cache": "^1",
"doctrine/dbal": "^2.13.3",
"doctrine/orm": "^2.11",
"doctrine/dbal": "^3.2",
"doctrine/orm": "^2.14",
"doctrine/persistence": "^1.3.5|^2.0",
"illuminate/auth": "^9.0",
"illuminate/console": "^9.0",
Expand All @@ -31,6 +30,7 @@
"illuminate/support": "^9.0",
"illuminate/validation": "^9.0",
"illuminate/view": "^9.0",
"symfony/cache": "^6.0",
"symfony/serializer": "^5.0|^6.0",
"symfony/yaml": "^5.0|^6.0"
},
Expand Down Expand Up @@ -76,4 +76,4 @@
}
}
}
}
}
3 changes: 1 addition & 2 deletions config/doctrine.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
'dev' => env('APP_DEBUG', false),
'meta' => env('DOCTRINE_METADATA', 'annotations'),
'connection' => env('DB_CONNECTION', 'mysql'),
'namespaces' => [],
'paths' => [
base_path('app/Entities')
],
Expand Down Expand Up @@ -160,7 +159,7 @@
| Configure meta-data, query and result caching here.
| Optionally you can enable second level caching.
|
| Available: apc|array|file|illuminate|memcached|php_file|redis|void
| Available: apc|array|file|illuminate|memcached|php_file|redis
|
*/
'cache' => [
Expand Down
12 changes: 7 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
keithbrink marked this conversation as resolved.
Show resolved Hide resolved
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
4 changes: 2 additions & 2 deletions src/Auth/Passwords/DoctrineTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function createNewToken()
*/
protected function getTable()
{
$schema = $this->connection->getSchemaManager();
$schema = $this->connection->createSchemaManager();

if (!$schema->tablesExist($this->table)) {
$schema->createTable($this->getTableDefinition());
Expand All @@ -262,7 +262,7 @@ public function getConnection()
}

/**
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Exception
* @return Table
*/
protected function getTableDefinition()
Expand Down
12 changes: 4 additions & 8 deletions src/Configuration/Cache/ArrayCacheProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

namespace LaravelDoctrine\ORM\Configuration\Cache;

use Doctrine\Common\Cache\ArrayCache;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use LaravelDoctrine\ORM\Configuration\Driver;

class ArrayCacheProvider implements Driver
{
/**
* @param array $settings
*
* @return ArrayCache
*/
public function resolve(array $settings = [])
public function resolve(array $settings = []): CacheItemPoolInterface
{
return new ArrayCache();
return new ArrayAdapter;
}
}
22 changes: 12 additions & 10 deletions src/Configuration/Cache/FileCacheProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

use Doctrine\Common\Cache\FilesystemCache;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Foundation\Application;
use LaravelDoctrine\ORM\Configuration\Driver;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

use function storage_path;

class FileCacheProvider implements Driver
Expand All @@ -22,17 +26,15 @@ public function __construct(Repository $config)
$this->config = $config;
}

/**
* @param array $settings
*
* @return FilesystemCache
*/
public function resolve(array $settings = [])
{
$path = $settings['path'] ?? $this->config->get('cache.stores.file.path', storage_path('framework/cache'));
public function resolve(array $settings = []): CacheItemPoolInterface
{
$path = $settings['path'] ?? $this->config->get('cache.stores.file.path', storage_path('framework/cache'));
$namespace = $settings['namespace'] ?? $this->config->get('doctrine.cache.namespace', 'doctrine-cache');

return new FilesystemCache(
$path
return new FilesystemAdapter(
$namespace,
0,
$path
);
}
}
97 changes: 0 additions & 97 deletions src/Configuration/Cache/IlluminateCacheAdapter.php

This file was deleted.

21 changes: 11 additions & 10 deletions src/Configuration/Cache/IlluminateCacheProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
namespace LaravelDoctrine\ORM\Configuration\Cache;

use const E_USER_DEPRECATED;

use Illuminate\Contracts\Cache\Factory;
use InvalidArgumentException;
use LaravelDoctrine\ORM\Configuration\Driver;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\Psr16Adapter;

class IlluminateCacheProvider implements Driver
{
Expand All @@ -18,7 +21,7 @@ class IlluminateCacheProvider implements Driver
* @var string
*/
protected $store;

/**
* @param Factory $cache
*/
Expand All @@ -27,12 +30,7 @@ public function __construct(Factory $cache)
$this->cache = $cache;
}

/**
* @param array $settings
*
* @return IlluminateCacheAdapter
*/
public function resolve(array $settings = [])
public function resolve(array $settings = []): CacheItemPoolInterface
{
$store = $this->store ?? $settings['store'] ?? null;

Expand All @@ -44,8 +42,11 @@ public function resolve(array $settings = [])
trigger_error('Using driver "' . $this->store . '" with a custom store is deprecated. Please use the "illuminate" driver.', E_USER_DEPRECATED);
}

return new IlluminateCacheAdapter(
$this->cache->store($store)
);
return new Psr16Adapter($this->cache->store($store));
}

public function getStore(): string
{
return $this->store;
}
}
21 changes: 10 additions & 11 deletions src/Configuration/Cache/PhpFileCacheProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace LaravelDoctrine\ORM\Configuration\Cache;

use Doctrine\Common\Cache\PhpFileCache;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Foundation\Application;
use LaravelDoctrine\ORM\Configuration\Driver;
use function storage_path;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;

class PhpFileCacheProvider implements Driver
{
Expand All @@ -22,17 +23,15 @@ public function __construct(Repository $config)
$this->config = $config;
}

/**
* @param array $settings
*
* @return PhpFileCache
*/
public function resolve(array $settings = [])
public function resolve(array $settings = []): CacheItemPoolInterface
{
$path = $settings['path'] ?? $this->config->get('cache.stores.file.path', storage_path('framework/cache'));
$path = $settings['path'] ?? $this->config->get('cache.stores.file.path', storage_path('framework/cache'));
$namespace = $settings['namespace'] ?? $this->config->get('doctrine.cache.namespace', 'doctrine-cache');

return new PhpFileCache(
$path
return new PhpFilesAdapter(
$namespace,
0,
$path,
);
}
}
19 changes: 0 additions & 19 deletions src/Configuration/Cache/VoidCacheProvider.php

This file was deleted.

Loading