Compare commits

...

4 Commits

Author SHA1 Message Date
Guy Sartorelli
840a0db70c
ENH Use symfony/validation logic 2024-09-25 10:31:09 +12:00
Guy Sartorelli
4b8f7586d2
API Use new names for renamed classes (#258) 2024-09-23 14:40:25 +12:00
github-actions
4488096f6e Merge branch '5' into 6 2024-09-21 23:58:16 +00:00
Guy Sartorelli
f7ee5d7fe8
ENH Don't use deprecated method (#259) 2024-09-19 14:05:01 +12:00
11 changed files with 16 additions and 44 deletions

View File

@ -11,7 +11,7 @@ use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse; use SilverStripe\Control\HTTPResponse;
use SilverStripe\Control\HTTPResponse_Exception; use SilverStripe\Control\HTTPResponse_Exception;
use SilverStripe\Forms\Form; use SilverStripe\Forms\Form;
use SilverStripe\ORM\ValidationResult; use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Security\Security; use SilverStripe\Security\Security;
use SilverStripe\Core\Extension; use SilverStripe\Core\Extension;

View File

@ -23,14 +23,14 @@ use SilverStripe\Forms\ListboxField;
use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\OptionsetField; use SilverStripe\Forms\OptionsetField;
use SilverStripe\Forms\ReadonlyField; use SilverStripe\Forms\ReadonlyField;
use SilverStripe\ORM\ArrayList; use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB; use SilverStripe\ORM\DB;
use SilverStripe\ORM\HasManyList; use SilverStripe\ORM\HasManyList;
use SilverStripe\ORM\ManyManyList; use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\FieldType\DBDate; use SilverStripe\ORM\FieldType\DBDate;
use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\SS_List; use SilverStripe\Model\List\SS_List;
use SilverStripe\Security\Group; use SilverStripe\Security\Group;
use SilverStripe\Security\Member; use SilverStripe\Security\Member;
use SilverStripe\Security\Permission; use SilverStripe\Security\Permission;

View File

@ -14,7 +14,7 @@ use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\HiddenField;
use SilverStripe\Forms\TextareaField; use SilverStripe\Forms\TextareaField;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ValidationException; use SilverStripe\Core\Validation\ValidationException;
use SilverStripe\Security\Security; use SilverStripe\Security\Security;
class ReviewContentHandler class ReviewContentHandler

View File

@ -13,7 +13,7 @@ use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DateField; use SilverStripe\Forms\DateField;
use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\SS_List; use SilverStripe\Model\List\SS_List;
use SilverStripe\Reports\Report; use SilverStripe\Reports\Report;
use SilverStripe\Security\Security; use SilverStripe\Security\Security;
use SilverStripe\SiteConfig\SiteConfig; use SilverStripe\SiteConfig\SiteConfig;

View File

@ -9,9 +9,9 @@ use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability;
use SilverStripe\Core\ClassInfo; use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList; use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\ArrayList; use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\SS_List; use SilverStripe\Model\List\SS_List;
use SilverStripe\Reports\Report; use SilverStripe\Reports\Report;
use SilverStripe\SiteConfig\SiteConfig; use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Versioned\Versioned; use SilverStripe\Versioned\Versioned;

View File

@ -8,13 +8,13 @@ use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability;
use SilverStripe\Control\Email\Email; use SilverStripe\Control\Email\Email;
use SilverStripe\Control\HTTPRequest; use SilverStripe\Control\HTTPRequest;
use SilverStripe\Dev\BuildTask; use SilverStripe\Dev\BuildTask;
use SilverStripe\ORM\ArrayList; use SilverStripe\Model\List\ArrayList;
use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\FieldType\DBField; use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\SS_List; use SilverStripe\Model\List\SS_List;
use SilverStripe\Security\Member; use SilverStripe\Security\Member;
use SilverStripe\SiteConfig\SiteConfig; use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\View\ArrayData; use SilverStripe\Model\ArrayData;
use SilverStripe\View\SSViewer; use SilverStripe\View\SSViewer;
/** /**
@ -30,7 +30,7 @@ class ContentReviewEmails extends BuildTask
*/ */
public function run($request) public function run($request)
{ {
if (!$this->isValidEmail($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) { if (!Email::is_valid_address($senderEmail = SiteConfig::current_site_config()->ReviewFrom)) {
throw new RuntimeException( throw new RuntimeException(
sprintf( sprintf(
'Provided sender email address is invalid: "%s".', 'Provided sender email address is invalid: "%s".',
@ -116,7 +116,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 (!Email::is_valid_address($owner->Email)) {
$this->invalid_emails[] = $owner->Name . ': ' . $owner->Email; $this->invalid_emails[] = $owner->Name . ': ' . $owner->Email;
return; return;
@ -188,12 +188,4 @@ class ContentReviewEmails extends BuildTask
'ToEmail' => $recipient->Email, 'ToEmail' => $recipient->Email,
]; ];
} }
/**
* Check validity of email
*/
protected function isValidEmail(?string $email): bool
{
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
}
} }

View File

@ -16,7 +16,7 @@ class ContentReviewOwnerMigrationTask extends BuildTask
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
Deprecation::withNoReplacement(function () { Deprecation::withSuppressedNotice(function () {
Deprecation::notice( Deprecation::notice(
'5.4.0', '5.4.0',
'Will be removed without equivalent functionality to replace it', 'Will be removed without equivalent functionality to replace it',

View File

@ -133,26 +133,6 @@ class ContentReviewNotificationTest extends SapphireTest
DBDatetime::clear_mock_now(); 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 * Deletes all pages except those passes in to the $ids parameter
* *

View File

@ -14,7 +14,7 @@ use SilverStripe\Forms\Form;
use SilverStripe\Forms\HiddenField; use SilverStripe\Forms\HiddenField;
use SilverStripe\Forms\TextareaField; use SilverStripe\Forms\TextareaField;
use SilverStripe\Security\Member; use SilverStripe\Security\Member;
use SilverStripe\ORM\ValidationException; use SilverStripe\Core\Validation\ValidationException;
class ReviewContentHandlerTest extends SapphireTest class ReviewContentHandlerTest extends SapphireTest
{ {

View File

@ -17,7 +17,7 @@ use SilverStripe\Security\Group;
use SilverStripe\Security\Member; use SilverStripe\Security\Member;
use SilverStripe\SiteConfig\SiteConfig; use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\Versioned\Versioned; use SilverStripe\Versioned\Versioned;
use SilverStripe\ORM\ArrayList; use SilverStripe\Model\List\ArrayList;
use SilverStripe\Dev\FunctionalTest; use SilverStripe\Dev\FunctionalTest;
use SilverStripe\ContentReview\Tests\SiteTreeContentReviewTestPage; use SilverStripe\ContentReview\Tests\SiteTreeContentReviewTestPage;

View File

@ -4,7 +4,7 @@ namespace SilverStripe\ContentReview\Tests;
use Page; use Page;
use SilverStripe\Dev\TestOnly; use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\ArrayList; use SilverStripe\Model\List\ArrayList;
/** /**
* Mock Page class with canReviewContent method to return false on first call * Mock Page class with canReviewContent method to return false on first call