mirror of
https://github.com/silverstripe/silverstripe-contentreview
synced 2024-10-22 17:05:47 +02:00
Merge branch '5' into 6
# Conflicts: # composer.json # src/Tasks/ContentReviewEmails.php
This commit is contained in:
commit
ef588a5ee0
@ -9,6 +9,7 @@ use SilverStripe\Control\Email\Email;
|
|||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
use SilverStripe\Dev\BuildTask;
|
use SilverStripe\Dev\BuildTask;
|
||||||
use SilverStripe\Model\List\ArrayList;
|
use SilverStripe\Model\List\ArrayList;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\ORM\FieldType\DBField;
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
use SilverStripe\Model\List\SS_List;
|
use SilverStripe\Model\List\SS_List;
|
||||||
@ -30,7 +31,8 @@ class ContentReviewEmails extends BuildTask
|
|||||||
*/
|
*/
|
||||||
public function run($request)
|
public function run($request)
|
||||||
{
|
{
|
||||||
if (!$this->isValidEmail($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) {
|
$senderEmail = SiteConfig::current_site_config()->ReviewFrom;
|
||||||
|
if (!Deprecation::withSuppressedNotice(fn() => $this->isValidEmail($senderEmail))) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
sprintf(
|
sprintf(
|
||||||
'Provided sender email address is invalid: "%s".',
|
'Provided sender email address is invalid: "%s".',
|
||||||
@ -116,7 +118,7 @@ class ContentReviewEmails extends BuildTask
|
|||||||
$siteConfig = SiteConfig::current_site_config();
|
$siteConfig = SiteConfig::current_site_config();
|
||||||
$owner = Member::get()->byID($ownerID);
|
$owner = Member::get()->byID($ownerID);
|
||||||
|
|
||||||
if (!$this->isValidEmail($owner->Email)) {
|
if (!Deprecation::withSuppressedNotice(fn() => $this->isValidEmail($owner->Email))) {
|
||||||
$this->invalid_emails[] = $owner->Name . ': ' . $owner->Email;
|
$this->invalid_emails[] = $owner->Name . ': ' . $owner->Email;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -191,9 +193,11 @@ class ContentReviewEmails extends BuildTask
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check validity of email
|
* Check validity of email
|
||||||
|
* @deprecated 5.4.0 Use SilverStripe\Control\Email\Email::is_valid_address() instead.
|
||||||
*/
|
*/
|
||||||
protected function isValidEmail(?string $email): bool
|
protected function isValidEmail(?string $email): bool
|
||||||
{
|
{
|
||||||
|
Deprecation::notice('5.4.0', 'Use ' . Email::class . '::is_valid_address() instead.');
|
||||||
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
|
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ use SilverStripe\ContentReview\Extensions\ContentReviewOwner;
|
|||||||
use SilverStripe\ContentReview\Extensions\SiteTreeContentReview;
|
use SilverStripe\ContentReview\Extensions\SiteTreeContentReview;
|
||||||
use SilverStripe\ContentReview\Tasks\ContentReviewEmails;
|
use SilverStripe\ContentReview\Tasks\ContentReviewEmails;
|
||||||
use SilverStripe\Control\HTTPRequest;
|
use SilverStripe\Control\HTTPRequest;
|
||||||
|
use SilverStripe\Dev\Deprecation;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
use SilverStripe\Security\Group;
|
use SilverStripe\Security\Group;
|
||||||
@ -145,12 +146,14 @@ class ContentReviewNotificationTest extends SapphireTest
|
|||||||
$member = $this->objFromFixture(Member::class, 'author');
|
$member = $this->objFromFixture(Member::class, 'author');
|
||||||
$task = new ContentReviewEmails();
|
$task = new ContentReviewEmails();
|
||||||
|
|
||||||
|
Deprecation::withSuppressedNotice(function () use ($method, $task, $member) {
|
||||||
$this->assertTrue($method->invokeArgs($task, [$member->Email]));
|
$this->assertTrue($method->invokeArgs($task, [$member->Email]));
|
||||||
$this->assertTrue($method->invokeArgs($task, ['correct.email@example.com']));
|
$this->assertTrue($method->invokeArgs($task, ['correct.email@example.com']));
|
||||||
|
|
||||||
$this->assertFalse($method->invokeArgs($task, [null]));
|
$this->assertFalse($method->invokeArgs($task, [null]));
|
||||||
$this->assertFalse($method->invokeArgs($task, ['broken.email']));
|
$this->assertFalse($method->invokeArgs($task, ['broken.email']));
|
||||||
$this->assertFalse($method->invokeArgs($task, ['broken@email']));
|
$this->assertFalse($method->invokeArgs($task, ['broken@email']));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user