Skip to content

EspoCRM – Open Source CRM Application

Ref

Yurii9f1763991595
diff --git a/application/Espo/Core/DataManager.php b/application/Espo/Core/DataManager.php
index 3dd74d85ab..bb9f0dd8e4 100644
--- a/application/Espo/Core/DataManager.php
+++ b/application/Espo/Core/DataManager.php
@@ -36,6 +36,7 @@ use Espo\Core\ORM\EntityManagerProxy;
use Espo\Core\Utils\Cache\DataCacheProvider;
use Espo\Core\Utils\Cache\Exceptions\PersistenceError;
use Espo\Core\Utils\Database\Helper as DatabaseHelper;
+use Espo\Core\Utils\Database\Platform;
use Espo\Core\Utils\Database\Schema\RebuildMode;
use Espo\Core\Utils\Database\Schema\SchemaManagerProxy;
use Espo\Core\Utils\DataCache;
@@ -149,7 +150,7 @@ class DataManager
*/
public function rebuildDatabase(?array $entityTypeList = null, string $mode = RebuildMode::SOFT): void
{
- if ($entityTypeList && $this->config->get('database.platform') === 'Postgresql') {
+ if ($entityTypeList && $this->config->get('database.platform') === Platform::POSTGRESQL) {
// Prevents sequences from being dropped.
// @todo Refactor.
$entityTypeList = null;
@@ -244,7 +245,7 @@ class DataManager
{
$databaseParams = $this->databaseParamsFactory->create();
- if ($databaseParams->getPlatform() !== 'Mysql') {
+ if ($databaseParams->getPlatform() !== Platform::MYSQL) {
return;
}
diff --git a/application/Espo/Core/ORM/DatabaseParamsFactory.php b/application/Espo/Core/ORM/DatabaseParamsFactory.php
index a85b3e4306..727f31f46e 100644
--- a/application/Espo/Core/ORM/DatabaseParamsFactory.php
+++ b/application/Espo/Core/ORM/DatabaseParamsFactory.php
@@ -30,13 +30,14 @@
namespace Espo\Core\ORM;
use Espo\Core\Utils\Config;
+use Espo\Core\Utils\Database\Platform;
use Espo\ORM\DatabaseParams;
use RuntimeException;
class DatabaseParamsFactory
{
- private const DEFAULT_PLATFORM = 'Mysql';
+ private const string DEFAULT_PLATFORM = Platform::MYSQL;
public function __construct(private Config $config) {}
diff --git a/application/Espo/Core/Utils/Database/DefaultConfigDataProvider.php b/application/Espo/Core/Utils/Database/DefaultConfigDataProvider.php
index f1e50724ba..a80d82a18a 100644
--- a/application/Espo/Core/Utils/Database/DefaultConfigDataProvider.php
+++ b/application/Espo/Core/Utils/Database/DefaultConfigDataProvider.php
@@ -33,7 +33,7 @@ use Espo\Core\Utils\Config;
class DefaultConfigDataProvider implements ConfigDataProvider
{
- private const DEFAULT_PLATFORM = 'Mysql';
+ private const string DEFAULT_PLATFORM = Platform::MYSQL;
public function __construct(private Config $config) {}
diff --git a/application/Espo/Core/Utils/Database/Platform.php b/application/Espo/Core/Utils/Database/Platform.php
new file mode 100644
index 0000000000..502e165127
--- /dev/null
+++ b/application/Espo/Core/Utils/Database/Platform.php
@@ -0,0 +1,39 @@
+<?php
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM – Open Source CRM application.
+ * Copyright (C) 2014-2026 EspoCRM, Inc.
+ * Website: https://www.espocrm.com
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU Affero General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
+ ************************************************************************/
+
+namespace Espo\Core\Utils\Database;
+
+/**
+ * @since 10.1.0
+ */
+class Platform
+{
+ public const string MYSQL = 'Mysql';
+ public const string POSTGRESQL = 'Postgresql';
+}
diff --git a/application/Espo/Core/Utils/SystemRequirements.php b/application/Espo/Core/Utils/SystemRequirements.php
index 9675bd77ab..f64c1152b5 100644
--- a/application/Espo/Core/Utils/SystemRequirements.php
+++ b/application/Espo/Core/Utils/SystemRequirements.php
@@ -32,17 +32,15 @@ namespace Espo\Core\Utils;
use Espo\Core\ORM\DatabaseParamsFactory;
use Espo\Core\Utils\Database\ConfigDataProvider;
use Espo\Core\Utils\Database\Helper as DatabaseHelper;
+use Espo\Core\Utils\Database\Platform;
use Espo\Core\Utils\File\Manager as FileManager;
class SystemRequirements
{
- private const PLATFORM_MYSQL = 'Mysql';
- private const PLATFORM_POSTGRESQL = 'Postgresql';
-
/** @var array<string, string> */
private $pdoExtensionMap = [
- self::PLATFORM_MYSQL => 'pdo_mysql',
- self::PLATFORM_POSTGRESQL => 'pdo_pgsql',
+ Platform::MYSQL => 'pdo_mysql',
+ Platform::POSTGRESQL => 'pdo_pgsql',
];
public function __construct(
@@ -141,7 +139,7 @@ class SystemRequirements
{
$platform = $this->databaseConfig->getPlatform() ?:
$this->config->get('database.platform') ?:
- self::PLATFORM_MYSQL;
+ Platform::MYSQL;
return $this->pdoExtensionMap[$platform] ?? null;
}
diff --git a/application/Espo/ORM/EntityManager.php b/application/Espo/ORM/EntityManager.php
index fb451c6ac3..a28179699c 100644
--- a/application/Espo/ORM/EntityManager.php
+++ b/application/Espo/ORM/EntityManager.php
@@ -29,6 +29,7 @@
namespace Espo\ORM;
+use Espo\Core\Utils\Database\Platform;
use Espo\ORM\Defs\Defs;
use Espo\ORM\Executor\DefaultQueryExecutor;
use Espo\ORM\Executor\DefaultSqlExecutor;
@@ -140,7 +141,7 @@ class EntityManager
$className = BaseLocker::class;
- if ($platform === 'Mysql') {
+ if ($platform === Platform::MYSQL) {
$className = MysqlLocker::class;
}
diff --git a/install/core/Installer.php b/install/core/Installer.php
index 174bfe20a7..1c424f60c4 100644
--- a/install/core/Installer.php
+++ b/install/core/Installer.php
@@ -36,6 +36,7 @@ use Espo\Core\InjectableFactory;
use Espo\Core\ORM\DatabaseParamsFactory;
use Espo\Core\Utils\Database\ConfigDataProvider;
use Espo\Core\Utils\Database\Dbal\ConnectionFactoryFactory;
+use Espo\Core\Utils\Database\Platform;
use Espo\Core\Utils\Id\RecordIdGenerator;
use Espo\Core\Utils\ScheduledJob as ScheduledJobUtil;
use Espo\Core\Utils\Util;
@@ -301,7 +302,7 @@ class Installer
bool $requiredOnly = false,
?array $additionalData = null
): array {
- $platform = $additionalData['databaseParams']['platform'] ?? 'Mysql';
+ $platform = $additionalData['databaseParams']['platform'] ?? Platform::MYSQL;
$dbConfigDataProvider = new DatabaseConfigDataProvider($platform);
diff --git a/tests/integration/Espo/Core/Utils/Database/Fields/AddressFieldTest.php b/tests/integration/Espo/Core/Utils/Database/Fields/AddressFieldTest.php
index eb9d667fbe..387fcf8d8d 100644
--- a/tests/integration/Espo/Core/Utils/Database/Fields/AddressFieldTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/Fields/AddressFieldTest.php
@@ -30,6 +30,7 @@
namespace tests\integration\Espo\Core\Utils\Database\Fields;
use Doctrine\DBAL\Types\StringType;
+use Espo\Core\Utils\Database\Platform;
use integration\Core\NoTransaction;
class AddressFieldTest extends Base
@@ -53,7 +54,7 @@ class AddressFieldTest extends Base
$this->assertEquals($length, $column->getLength());
$this->assertFalse($column->getNotnull());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertEquals('utf8mb4_unicode_ci', $column->getCollation());
}
}
diff --git a/tests/integration/Espo/Core/Utils/Database/Fields/ArrayFieldTest.php b/tests/integration/Espo/Core/Utils/Database/Fields/ArrayFieldTest.php
index 346f446a27..c95a2565b4 100644
--- a/tests/integration/Espo/Core/Utils/Database/Fields/ArrayFieldTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/Fields/ArrayFieldTest.php
@@ -30,6 +30,7 @@
namespace tests\integration\Espo\Core\Utils\Database\Fields;
use Espo\Core\Utils\Database\Dbal\Types\MediumtextType;
+use Espo\Core\Utils\Database\Platform;
use integration\Core\NoTransaction;
class ArrayFieldTest extends Base
@@ -42,7 +43,7 @@ class ArrayFieldTest extends Base
$this->assertNotNull($column);
$this->assertFalse($column->getNotnull());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertInstanceOf(MediumtextType::class, $column->getType());
$this->assertEquals('utf8mb4_unicode_ci', $column->getCollation());
}
diff --git a/tests/integration/Espo/Core/Utils/Database/Fields/BooleanFieldTest.php b/tests/integration/Espo/Core/Utils/Database/Fields/BooleanFieldTest.php
index 8dd2f5ec75..c8237ae491 100644
--- a/tests/integration/Espo/Core/Utils/Database/Fields/BooleanFieldTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/Fields/BooleanFieldTest.php
@@ -30,6 +30,7 @@
namespace tests\integration\Espo\Core\Utils\Database\Fields;
use Doctrine\DBAL\Types\BooleanType;
+use Espo\Core\Utils\Database\Platform;
use integration\Core\NoTransaction;
#[NoTransaction]
@@ -43,7 +44,7 @@ class BooleanFieldTest extends Base
$this->assertInstanceOf(BooleanType::class, $column->getType());
$this->assertTrue($column->getNotnull());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertEquals(0, $column->getDefault());
} else {
$this->assertFalse($column->getDefault());
@@ -63,7 +64,7 @@ class BooleanFieldTest extends Base
$this->assertInstanceOf(BooleanType::class, $column->getType());
$this->assertTrue($column->getNotnull());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertEquals(1, $column->getDefault());
} else {
$this->assertTrue($column->getDefault());
diff --git a/tests/integration/Espo/Core/Utils/Database/Fields/CurrencyFieldTest.php b/tests/integration/Espo/Core/Utils/Database/Fields/CurrencyFieldTest.php
index 982b3c6cf0..b4f863716a 100644
--- a/tests/integration/Espo/Core/Utils/Database/Fields/CurrencyFieldTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/Fields/CurrencyFieldTest.php
@@ -31,6 +31,7 @@ namespace tests\integration\Espo\Core\Utils\Database\Fields;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\DBAL\Types\StringType;
+use Espo\Core\Utils\Database\Platform;
use integration\Core\NoTransaction;
#[NoTransaction]
@@ -52,7 +53,7 @@ class CurrencyFieldTest extends Base
$this->assertInstanceOf($typeClass, $column->getType());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertEquals($collation, $column->getCollation());
}
}
diff --git a/tests/integration/Espo/Core/Utils/Database/Fields/FileFieldTest.php b/tests/integration/Espo/Core/Utils/Database/Fields/FileFieldTest.php
index 572c9414e7..22c089ab9e 100644
--- a/tests/integration/Espo/Core/Utils/Database/Fields/FileFieldTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/Fields/FileFieldTest.php
@@ -30,6 +30,7 @@
namespace tests\integration\Espo\Core\Utils\Database\Fields;
use Doctrine\DBAL\Types\StringType;
+use Espo\Core\Utils\Database\Platform;
use integration\Core\NoTransaction;
#[NoTransaction]
@@ -44,7 +45,7 @@ class FileFieldTest extends Base
$this->assertFalse($column->getNotnull());
$this->assertEquals(17, $column->getLength());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertEquals('utf8mb4_unicode_ci', $column->getCollation());
}
}
diff --git a/tests/integration/Espo/Core/Utils/Database/Fields/TextFieldTest.php b/tests/integration/Espo/Core/Utils/Database/Fields/TextFieldTest.php
index 947ac68cbe..7e0f00f255 100644
--- a/tests/integration/Espo/Core/Utils/Database/Fields/TextFieldTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/Fields/TextFieldTest.php
@@ -31,6 +31,7 @@ namespace tests\integration\Espo\Core\Utils\Database\Fields;
use Espo\Core\Utils\Database\Dbal\Types\LongtextType;
use Espo\Core\Utils\Database\Dbal\Types\MediumtextType;
+use Espo\Core\Utils\Database\Platform;
use integration\Core\NoTransaction;
#[NoTransaction]
@@ -43,7 +44,7 @@ class TextFieldTest extends Base
$this->assertNotNull($column);
$this->assertFalse($column->getNotnull());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertInstanceOf(MediumtextType::class, $column->getType());
$this->assertEquals('utf8mb4_unicode_ci', $column->getCollation());
}
@@ -64,7 +65,7 @@ class TextFieldTest extends Base
$this->assertNotNull($column);
$this->assertFalse($column->getNotnull());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertInstanceOf(LongtextType::class, $column->getType());
$this->assertEquals('utf8mb4_unicode_ci', $column->getCollation());
}
@@ -87,7 +88,7 @@ class TextFieldTest extends Base
$this->assertNotNull($column);
$this->assertFalse($column->getNotnull());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertInstanceOf(LongtextType::class, $column->getType());
$this->assertEquals('utf8mb4_unicode_ci', $column->getCollation());
}
diff --git a/tests/integration/Espo/Core/Utils/Database/Fields/VarcharFieldTest.php b/tests/integration/Espo/Core/Utils/Database/Fields/VarcharFieldTest.php
index 538d4db247..96e8cf0502 100644
--- a/tests/integration/Espo/Core/Utils/Database/Fields/VarcharFieldTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/Fields/VarcharFieldTest.php
@@ -30,6 +30,7 @@
namespace tests\integration\Espo\Core\Utils\Database\Fields;
use Doctrine\DBAL\Types\StringType;
+use Espo\Core\Utils\Database\Platform;
use integration\Core\NoTransaction;
#[NoTransaction]
@@ -43,7 +44,7 @@ class VarcharFieldTest extends Base
$this->assertEquals(100, $column->getLength());
$this->assertFalse($column->getNotnull());
- if ($this->getPlatform() === 'Mysql') {
+ if ($this->getPlatform() === Platform::MYSQL) {
$this->assertEquals('utf8mb4_unicode_ci', $column->getCollation());
}
diff --git a/tests/integration/Espo/Core/Utils/Database/FulltextIndex/CheckCreatedIndexTest.php b/tests/integration/Espo/Core/Utils/Database/FulltextIndex/CheckCreatedIndexTest.php
index 5298830a4c..19982c13fa 100644
--- a/tests/integration/Espo/Core/Utils/Database/FulltextIndex/CheckCreatedIndexTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/FulltextIndex/CheckCreatedIndexTest.php
@@ -33,6 +33,7 @@ use Doctrine\DBAL\Schema\Index\IndexType;
use Doctrine\DBAL\Schema\Table;
use Espo\Core\ORM\DatabaseParamsFactory;
use Espo\Core\Utils\Database\Helper;
+use Espo\Core\Utils\Database\Platform;
use Espo\Core\Utils\Util;
use PHPUnit\Framework\Attributes\DataProvider;
use RuntimeException;
@@ -58,7 +59,7 @@ class CheckCreatedIndexTest extends BaseTestCase
#[DataProvider('entityTypeList')]
public function testCreatedIndexes(string $entityType): void
{
- if ($this->getPlatform() === 'Postgresql') {
+ if ($this->getPlatform() === Platform::POSTGRESQL) {
// DBAL uses two different codes to fetch indexes.
return;
}
diff --git a/tests/integration/Espo/Core/Utils/Database/HelperTest.php b/tests/integration/Espo/Core/Utils/Database/HelperTest.php
index a6f550be90..b085b77253 100644
--- a/tests/integration/Espo/Core/Utils/Database/HelperTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/HelperTest.php
@@ -32,6 +32,7 @@ namespace tests\integration\Espo\Core\Utils\Database;
use Espo\Core\ORM\DatabaseParamsFactory;
use Espo\Core\Utils\Database\Helper;
use Doctrine\DBAL\Connection;
+use Espo\Core\Utils\Database\Platform;
use PDO;
use tests\integration\Core\BaseTestCase;
@@ -72,7 +73,7 @@ class HelperTest extends BaseTestCase
$this->initTest();
switch ($this->getPlatform()) {
- case 'Mysql':
+ case Platform::MYSQL:
$this->assertContains($this->helper->getType(), [
'MySQL',
'MariaDB',
@@ -80,7 +81,7 @@ class HelperTest extends BaseTestCase
break;
- case 'Postgresql':
+ case Platform::POSTGRESQL:
$this->assertEquals('PostgreSQL', $this->helper->getType());
break;
diff --git a/tests/integration/Espo/Core/Utils/Database/RebuildTest.php b/tests/integration/Espo/Core/Utils/Database/RebuildTest.php
index c89473d080..8b9d8dbd2f 100644
--- a/tests/integration/Espo/Core/Utils/Database/RebuildTest.php
+++ b/tests/integration/Espo/Core/Utils/Database/RebuildTest.php
@@ -34,6 +34,7 @@ use Espo\Core\ORM\DatabaseParamsFactory;
use Espo\Core\ORM\Type\FieldType;
use Espo\Core\Templates\Entities\Base;
use Espo\Core\Utils\Database\Helper;
+use Espo\Core\Utils\Database\Platform;
use Espo\Core\Utils\Database\Schema\RebuildMode;
use Espo\ORM\Defs\Params\FieldParam;
use Espo\ORM\Entity;
@@ -182,14 +183,14 @@ class RebuildTest extends BaseTestCase
$this->assertEquals(null, $entity->get('testSecond'));
//
- if ($this->getPlatform() === 'Postgresql') {
+ if ($this->getPlatform() === Platform::POSTGRESQL) {
$entity->set('testSecond', 4);
$em->saveEntity($entity);
}
// Enable autoincrement back.
- if ($this->getPlatform() !== 'Postgresql') {
+ if ($this->getPlatform() !== Platform::POSTGRESQL) {
$this->runAutoincrementBack($entity, $table);
}