Skip to content

EspoCRM – Open Source CRM Application

Fix email/phone saver

Yurii74c0dcf30084
diff --git a/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php b/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php
index eaba3b5de8..33cae4b1ef 100644
--- a/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php
+++ b/application/Espo/Core/FieldProcessing/EmailAddress/Saver.php
@@ -591,8 +591,6 @@ class Saver implements SaverInterface
return;
}
- $one->set(EmailAddress::FIELD_PRIMARY, true);
-
- $this->entityManager->saveEntity($one);
+ $relation->updateColumns($one, ['primary' => true]);
}
}
diff --git a/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php b/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php
index 0a197b509b..6f91d6eaeb 100644
--- a/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php
+++ b/application/Espo/Core/FieldProcessing/PhoneNumber/Saver.php
@@ -32,7 +32,6 @@ namespace Espo\Core\FieldProcessing\PhoneNumber;
use Espo\Core\FieldProcessing\Loader\Params as LoeaderParams;
use Espo\Core\ORM\Repository\Option\SaveOption;
use Espo\Core\ORM\Type\FieldType;
-use Espo\Entities\EmailAddress;
use Espo\Entities\PhoneNumber;
use Espo\ORM\Name\Attribute;
use Espo\ORM\Repository\RDBRelation;
@@ -603,8 +602,6 @@ class Saver implements SaverInterface
return;
}
- $one->set(EmailAddress::FIELD_PRIMARY, true);
-
- $this->entityManager->saveEntity($one);
+ $relation->updateColumns($one, ['primary' => true]);
}
}
diff --git a/application/Espo/Entities/EmailAddress.php b/application/Espo/Entities/EmailAddress.php
index 682231fd38..940668e952 100644
--- a/application/Espo/Entities/EmailAddress.php
+++ b/application/Espo/Entities/EmailAddress.php
@@ -40,8 +40,6 @@ class EmailAddress extends Entity
public const RELATION_ENTITY_EMAIL_ADDRESS = 'EntityEmailAddress';
- public const string FIELD_PRIMARY = 'primary';
-
/**
* @param string $value
* @return void
diff --git a/application/Espo/Entities/PhoneNumber.php b/application/Espo/Entities/PhoneNumber.php
index e8b355d92f..9c1855d2c9 100644
--- a/application/Espo/Entities/PhoneNumber.php
+++ b/application/Espo/Entities/PhoneNumber.php
@@ -40,8 +40,6 @@ class PhoneNumber extends Entity
public const RELATION_ENTITY_PHONE_NUMBER = 'EntityPhoneNumber';
- public const string FIELD_PRIMARY = 'primary';
-
/**
* @param string $value
* @return void
diff --git a/tests/integration/Espo/Core/Authentication/Oidc/UserInfoPopulatorTest.php b/tests/integration/Espo/Core/Authentication/Oidc/UserInfoPopulatorTest.php
index 6d7d9d63f6..383e77f951 100644
--- a/tests/integration/Espo/Core/Authentication/Oidc/UserInfoPopulatorTest.php
+++ b/tests/integration/Espo/Core/Authentication/Oidc/UserInfoPopulatorTest.php
@@ -104,8 +104,8 @@ class UserInfoPopulatorTest extends BaseTestCase
$em->saveEntity($user);
$em->refreshEntity($user);
- $this->assertNull($user->getEmailAddress());
- $this->assertNull($user->getPhoneNumber());
+ $this->assertEquals('[email protected]', $user->getEmailAddress());
+ $this->assertEquals('+200', $user->getPhoneNumber());
$this->assertCount(1, $user->getEmailAddressGroup()->getList());
$this->assertCount(1, $user->getPhoneNumberGroup()->getList());