Compare commits

...

6 Commits

Author SHA1 Message Date
Guy Sartorelli
a31f35ecf5
Merge cecbcb46121322298a0ede816d79f6ebcd934e9d into ef588a5ee0ce2a6ca2b3db4ad4cd60f37b3a7af1 2024-09-25 21:46:00 +00:00
Guy Sartorelli
cecbcb4612
ENH Use symfony/validation logic 2024-09-26 09:45:50 +12:00
Guy Sartorelli
ef588a5ee0
Merge branch '5' into 6
# Conflicts:
#	composer.json
#	src/Tasks/ContentReviewEmails.php
2024-09-26 09:24:45 +12:00
Guy Sartorelli
40e45cda53
API Deprecate isValidEmail() method (#262) 2024-09-25 16:11:45 +12:00
Guy Sartorelli
3f09b871c3
Merge pull request #260 from creative-commoners/pulls/5/framework-version
DEP Increase minimum version of silverstripe/framework
2024-09-24 09:39:51 +12:00
Steve Boyd
9150258f90 DEP Increase minimum version of silverstripe/framework 2024-09-23 15:15:09 +12:00
2 changed files with 3 additions and 30 deletions

View File

@ -30,7 +30,8 @@ class ContentReviewEmails extends BuildTask
*/
public function run($request)
{
if (!$this->isValidEmail($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) {
$senderEmail = SiteConfig::current_site_config()->ReviewFrom;
if (!Email::is_valid_address($senderEmail)) {
throw new RuntimeException(
sprintf(
'Provided sender email address is invalid: "%s".',
@ -116,7 +117,7 @@ class ContentReviewEmails extends BuildTask
$siteConfig = SiteConfig::current_site_config();
$owner = Member::get()->byID($ownerID);
if (!$this->isValidEmail($owner->Email)) {
if (!Email::is_valid_address($owner->Email)) {
$this->invalid_emails[] = $owner->Name . ': ' . $owner->Email;
return;
@ -188,12 +189,4 @@ class ContentReviewEmails extends BuildTask
'ToEmail' => $recipient->Email,
];
}
/**
* Check validity of email
*/
protected function isValidEmail(?string $email): bool
{
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
}
}

View File

@ -133,26 +133,6 @@ class ContentReviewNotificationTest extends SapphireTest
DBDatetime::clear_mock_now();
}
/**
* Test that provided email is valid
*/
public function testIsValidEmail()
{
$class = new ReflectionClass(ContentReviewEmails::class);
$method = $class->getMethod('isValidEmail');
$method->setAccessible(true);
$member = $this->objFromFixture(Member::class, 'author');
$task = new ContentReviewEmails();
$this->assertTrue($method->invokeArgs($task, [$member->Email]));
$this->assertTrue($method->invokeArgs($task, ['correct.email@example.com']));
$this->assertFalse($method->invokeArgs($task, [null]));
$this->assertFalse($method->invokeArgs($task, ['broken.email']));
$this->assertFalse($method->invokeArgs($task, ['broken@email']));
}
/**
* Deletes all pages except those passes in to the $ids parameter
*