File tree 6 files changed +54
-7
lines changed
6 files changed +54
-7
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,16 @@ jobs:
43
43
dependencies :
44
44
- " highest"
45
45
extension :
46
+ - " sqlite3"
46
47
- " pdo_sqlite"
47
48
include :
48
49
- os : " ubuntu-20.04"
49
50
php-version : " 7.4"
50
51
dependencies : " lowest"
51
52
extension : " pdo_sqlite"
52
53
- os : " ubuntu-22.04"
53
- php-version : " 7 .4"
54
- dependencies : " highest "
54
+ php-version : " 8 .4"
55
+ dependencies : " minimal "
55
56
extension : " sqlite3"
56
57
57
58
steps :
60
61
with :
61
62
fetch-depth : 2
62
63
64
+ - name : " Remove optional dependencies"
65
+ run : " composer remove --no-update --dev doctrine/cache"
66
+ if : " ${{ matrix.dependencies == 'minimal' }}"
67
+
63
68
- name : " Install PHP"
64
69
uses : " shivammathur/setup-php@v2"
65
70
with :
71
76
uses : " ramsey/composer-install@v3"
72
77
with :
73
78
composer-options : " --ignore-platform-req=php+"
74
- dependency-versions : " ${{ matrix.dependencies }}"
79
+ dependency-versions : " ${{ matrix.dependencies == 'minimal' && 'highest' || matrix.dependencies }}"
75
80
76
81
- name : " Print SQLite version"
77
82
run : >
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ awareness about deprecated code.
6
6
- Use of our low-overhead runtime deprecation API, details:
7
7
https://github.com/doctrine/deprecations/
8
8
9
+ # Upgrade to 3.10
10
+
11
+ The ` doctrine/cache ` package is now an optional dependency. If you are using the
12
+ ` Doctrine\DBAL\Cache ` classes, you need to require the ` doctrine/cache ` package
13
+ explicitly.
14
+
9
15
# Upgrade to 3.8
10
16
11
17
## Deprecated lock-related ` AbstractPlatform ` methods
Original file line number Diff line number Diff line change 33
33
"require" : {
34
34
"php" : " ^7.4 || ^8.0" ,
35
35
"composer-runtime-api" : " ^2" ,
36
- "doctrine/cache" : " ^1.11|^2.0" ,
37
36
"doctrine/deprecations" : " ^0.5.3|^1" ,
38
37
"doctrine/event-manager" : " ^1|^2" ,
39
38
"psr/cache" : " ^1|^2|^3" ,
40
39
"psr/log" : " ^1|^2|^3"
41
40
},
42
41
"require-dev" : {
42
+ "doctrine/cache" : " ^1.11|^2.0" ,
43
43
"doctrine/coding-standard" : " 12.0.0" ,
44
44
"fig/log-test" : " ^1" ,
45
45
"jetbrains/phpstorm-stubs" : " 2023.1" ,
51
51
"symfony/cache" : " ^5.4|^6.0|^7.0" ,
52
52
"symfony/console" : " ^4.4|^5.4|^6.0|^7.0"
53
53
},
54
+ "conflict" : {
55
+ "doctrine/cache" : " < 1.11"
56
+ },
54
57
"suggest" : {
55
58
"symfony/console" : " For helpful console commands such as SQL execution and import of files."
56
59
},
Original file line number Diff line number Diff line change 8
8
use Doctrine \DBAL \Types \Type ;
9
9
use Doctrine \Deprecations \Deprecation ;
10
10
use Psr \Cache \CacheItemPoolInterface ;
11
+ use RuntimeException ;
11
12
use TypeError ;
12
13
14
+ use function class_exists ;
13
15
use function get_class ;
14
16
use function hash ;
15
17
use function serialize ;
@@ -82,7 +84,19 @@ public function getResultCacheDriver()
82
84
__METHOD__ ,
83
85
);
84
86
85
- return $ this ->resultCache !== null ? DoctrineProvider::wrap ($ this ->resultCache ) : null ;
87
+ if ($ this ->resultCache === null ) {
88
+ return null ;
89
+ }
90
+
91
+ if (! class_exists (DoctrineProvider::class)) {
92
+ throw new RuntimeException (sprintf (
93
+ 'Calling %s() is not supported if the doctrine/cache package is not installed. '
94
+ . 'Try running "composer require doctrine/cache" or migrate cache access to PSR-6. ' ,
95
+ __METHOD__ ,
96
+ ));
97
+ }
98
+
99
+ return DoctrineProvider::wrap ($ this ->resultCache );
86
100
}
87
101
88
102
/** @return int */
Original file line number Diff line number Diff line change 10
10
use Doctrine \DBAL \Schema \SchemaManagerFactory ;
11
11
use Doctrine \Deprecations \Deprecation ;
12
12
use Psr \Cache \CacheItemPoolInterface ;
13
+ use RuntimeException ;
13
14
15
+ use function class_exists ;
14
16
use function func_num_args ;
17
+ use function interface_exists ;
18
+ use function sprintf ;
15
19
16
20
/**
17
21
* Configuration container for the Doctrine DBAL.
@@ -129,6 +133,14 @@ public function getResultCacheImpl(): ?Cache
129
133
__METHOD__ ,
130
134
);
131
135
136
+ if ($ this ->resultCache !== null && ! interface_exists (Cache::class)) {
137
+ throw new RuntimeException (sprintf (
138
+ 'Calling %s() is not supported if the doctrine/cache package is not installed. '
139
+ . 'Try running "composer require doctrine/cache" or migrate cache access to PSR-6. ' ,
140
+ __METHOD__ ,
141
+ ));
142
+ }
143
+
132
144
return $ this ->resultCacheImpl ;
133
145
}
134
146
@@ -137,8 +149,11 @@ public function getResultCacheImpl(): ?Cache
137
149
*/
138
150
public function setResultCache (CacheItemPoolInterface $ cache ): void
139
151
{
140
- $ this ->resultCacheImpl = DoctrineProvider::wrap ($ cache );
141
- $ this ->resultCache = $ cache ;
152
+ if (class_exists (DoctrineProvider::class)) {
153
+ $ this ->resultCacheImpl = DoctrineProvider::wrap ($ cache );
154
+ }
155
+
156
+ $ this ->resultCache = $ cache ;
142
157
}
143
158
144
159
/**
Original file line number Diff line number Diff line change @@ -40,6 +40,10 @@ public function testCachedQueryLegacy(): void
40
40
41
41
public function testCachedQueryLegacyWrapped (): void
42
42
{
43
+ if (! class_exists (DoctrineProvider::class)) {
44
+ self ::markTestSkipped ('This test requires the doctrine/cache package. ' );
45
+ }
46
+
43
47
$ cache = new ArrayAdapter ();
44
48
$ legacy = DoctrineProvider::wrap ($ cache );
45
49
$ this ->assertCachedQueryIsExecutedOnceAndYieldsTheSameResult ($ legacy , __FUNCTION__ );
You can’t perform that action at this time.
0 commit comments