mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #9887 from lekoala/patch-18
This commit is contained in:
commit
debf1ae9fb
@ -871,6 +871,11 @@ class Member extends DataObject
|
|||||||
*/
|
*/
|
||||||
public function onBeforeWrite()
|
public function onBeforeWrite()
|
||||||
{
|
{
|
||||||
|
// Remove any line-break or space characters accidentally added during a copy-paste operation
|
||||||
|
if ($this->Email) {
|
||||||
|
$this->Email = trim($this->Email);
|
||||||
|
}
|
||||||
|
|
||||||
// If a member with the same "unique identifier" already exists with a different ID, don't allow merging.
|
// If a member with the same "unique identifier" already exists with a different ID, don't allow merging.
|
||||||
// Note: This does not a full replacement for safeguards in the controller layer (e.g. in a registration form),
|
// Note: This does not a full replacement for safeguards in the controller layer (e.g. in a registration form),
|
||||||
// but rather a last line of defense against data inconsistencies.
|
// but rather a last line of defense against data inconsistencies.
|
||||||
|
@ -1593,4 +1593,12 @@ class MemberTest extends FunctionalTest
|
|||||||
|
|
||||||
$this->assertSame('Johnson', $member->getLastName(), 'getLastName should proxy to Surname');
|
$this->assertSame('Johnson', $member->getLastName(), 'getLastName should proxy to Surname');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEmailIsTrimmed()
|
||||||
|
{
|
||||||
|
$member = new Member();
|
||||||
|
$member->Email = " trimmed@test.com\r\n";
|
||||||
|
$member->write();
|
||||||
|
$this->assertNotNull(Member::get()->find('Email', 'trimmed@test.com'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user