Commit 28a9855 1 parent 4a467b2 commit 28a9855 Copy full SHA for 28a9855
File tree 3 files changed +35
-0
lines changed
3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 8
8
" BOMO\\ IcalBundle\\ Model\\ Event" ,
9
9
" BOMO\\ IcalBundle\\ Model\\ Timezone" ,
10
10
" BOMO\\ IcalBundle\\ Provider\\ IcsProvider" ,
11
+ " Doctrine\\ Bundle\\ DoctrineBundle\\ Middleware\\ DebugMiddleware" ,
11
12
" Doctrine\\ Common\\ Collections\\ Collection" ,
12
13
" Doctrine\\ Common\\ Collections\\ ReadableCollection" ,
13
14
" Doctrine\\ Common\\ EventSubscriber" ,
14
15
" Doctrine\\ DBAL\\ Connection" ,
16
+ " Doctrine\\ DBAL\\ Driver\\ Middleware" ,
17
+ " Doctrine\\ DBAL\\ Logging\\ Middleware" ,
15
18
" Doctrine\\ DBAL\\ Platforms\\ AbstractPlatform" ,
16
19
" Doctrine\\ DBAL\\ Types\\ ConversionException" ,
17
20
" Doctrine\\ DBAL\\ Types\\ DateImmutableType" ,
Original file line number Diff line number Diff line change 33
33
"twig/twig" : " ~3.7"
34
34
},
35
35
"require-dev" : {
36
+ "doctrine/doctrine-bundle" : " ^2.13" ,
36
37
"doctrine/orm" : " ^2.7" ,
37
38
"eluceo/ical" : " ^2.7" ,
38
39
"friendsofphp/php-cs-fixer" : " 3.68.3" ,
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Drenso \Shared \Database \Logger ;
4
+
5
+ use Doctrine \Bundle \DoctrineBundle \Middleware \DebugMiddleware ;
6
+ use Doctrine \DBAL \Connection ;
7
+ use Doctrine \DBAL \Driver \Middleware ;
8
+ use Doctrine \DBAL \Logging \Middleware as LoggingMiddleware ;
9
+
10
+ class DatabaseLoggerDisabler
11
+ {
12
+ /**
13
+ * Used to disable SQL logging to prevent memory issues.
14
+ * See https://jolicode.com/blog/how-to-fix-memory-leak-in-doctrine-migrations.
15
+ */
16
+ public static function disableSqlLogger (Connection $ connection ): void
17
+ {
18
+ $ configuration = $ connection ->getConfiguration ();
19
+
20
+ // Remove logging and debug middlewares from the configuration
21
+ $ filteredMiddlewares = array_filter (
22
+ $ configuration ->getMiddlewares (),
23
+ static fn (
24
+ Middleware $ middleware ,
25
+ ): bool => !($ middleware instanceof LoggingMiddleware || $ middleware instanceof DebugMiddleware),
26
+ );
27
+
28
+ // Update the configured middleware
29
+ $ configuration ->setMiddlewares ($ filteredMiddlewares );
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments