Skip to content

EspoCRM – Open Source CRM Application

Better recovery unique ID

Yurii8e5555c1ee0e
diff --git a/application/Espo/Core/Utils/Util.php b/application/Espo/Core/Utils/Util.php
index 56dc2d02c5..b7e4471828 100644
--- a/application/Espo/Core/Utils/Util.php
+++ b/application/Espo/Core/Utils/Util.php
@@ -581,18 +581,16 @@ class Util
/**
* Generate an ID with more entropy.
+ * @deprecated As of v10.1.0.
+ * @todo Remove in v11.0.
*/
public static function generateMoreEntropyId(): string
{
- return
- substr(md5(uniqid((string) rand(), true)), 0, 16) .
- substr(md5((string) rand()), 0, 4);
+ return self::generateCryptId();
}
/**
* Generate a crypt ID.
- *
- * @return string
*/
public static function generateCryptId(): string
{
diff --git a/application/Espo/Repositories/UniqueId.php b/application/Espo/Repositories/UniqueId.php
index 3c271173df..a66ed0c2ac 100644
--- a/application/Espo/Repositories/UniqueId.php
+++ b/application/Espo/Repositories/UniqueId.php
@@ -44,7 +44,7 @@ class UniqueId extends Database
{
$entity = parent::getNew();
- $entity->set(Field::NAME, Util::generateMoreEntropyId());
+ $entity->set(Field::NAME, Util::generateCryptId());
return $entity;
}
diff --git a/application/Espo/Resources/metadata/entityDefs/UniqueId.json b/application/Espo/Resources/metadata/entityDefs/UniqueId.json
index 44dd8e496e..09c9d6cbff 100644
--- a/application/Espo/Resources/metadata/entityDefs/UniqueId.json
+++ b/application/Espo/Resources/metadata/entityDefs/UniqueId.json
@@ -3,7 +3,8 @@
"name": {
"type": "varchar",
"required": true,
- "index": true
+ "index": true,
+ "maxLength": 64
},
"data": {
"type": "jsonObject"