From 2efc7244df323e3c0ebcc39d948f569af4d61ebf Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 22 Mar 2023 16:07:31 +0100 Subject: [PATCH] Internal: Avoid auto-generating Doctrine proxy files all the time in production env - refs BT#20616 --- main/inc/lib/database.lib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index f176ba1f6e..e8a3a7cc4c 100755 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -148,7 +148,11 @@ class Database $returnManager = false ) { $config = self::getDoctrineConfig($entityRootPath); - $config->setAutoGenerateProxyClasses(true); + $autoGenerate = Doctrine\Common\Proxy\AbstractProxyFactory::AUTOGENERATE_NEVER; + if (api_get_setting('server_type') == 'test') { + $autoGenerate = Doctrine\Common\Proxy\AbstractProxyFactory::AUTOGENERATE_ALWAYS; + } + $config->setAutoGenerateProxyClasses($autoGenerate); $config->setEntityNamespaces( [ @@ -779,7 +783,7 @@ class Database */ public static function getDoctrineConfig($path) { - $isDevMode = true; // Forces doctrine to use ArrayCache instead of apc/xcache/memcache/redis + $isDevMode = api_get_setting('server_type') == 'test'; // Forces doctrine to use ArrayCache instead of apc/xcache/memcache/redis $isSimpleMode = false; // related to annotations @Entity $cache = null; $path = !empty($path) ? $path : api_get_path(SYS_PATH);