From 9150258f90d2d34e1001ccb435e5e7828b3b9b17 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Mon, 23 Sep 2024 15:15:09 +1200 Subject: [PATCH 1/2] DEP Increase minimum version of silverstripe/framework --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6d41d1c..e08da0f 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "require": { "php": "^8.1", "silverstripe/vendor-plugin": "^2", - "silverstripe/framework": "^5", + "silverstripe/framework": "^5.4", "silverstripe/cms": "^5", "silverstripe/reports": "^5", "silverstripe/siteconfig": "^5" From 40e45cda53c414650ee9db415d344ab9f02dc371 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:11:45 +1200 Subject: [PATCH 2/2] API Deprecate isValidEmail() method (#262) --- src/Tasks/ContentReviewEmails.php | 8 ++++++-- tests/php/ContentReviewNotificationTest.php | 13 ++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Tasks/ContentReviewEmails.php b/src/Tasks/ContentReviewEmails.php index 2131796..d594e85 100644 --- a/src/Tasks/ContentReviewEmails.php +++ b/src/Tasks/ContentReviewEmails.php @@ -8,6 +8,7 @@ use SilverStripe\ContentReview\Compatibility\ContentReviewCompatability; use SilverStripe\Control\Email\Email; use SilverStripe\Control\HTTPRequest; use SilverStripe\Dev\BuildTask; +use SilverStripe\Dev\Deprecation; use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBField; @@ -30,7 +31,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 (!Deprecation::withSuppressedNotice(fn() => $this->isValidEmail($senderEmail))) { throw new RuntimeException( sprintf( 'Provided sender email address is invalid: "%s".', @@ -116,7 +118,7 @@ class ContentReviewEmails extends BuildTask $siteConfig = SiteConfig::current_site_config(); $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; return; @@ -191,9 +193,11 @@ class ContentReviewEmails extends BuildTask /** * Check validity of email + * @deprecated 5.4.0 Use SilverStripe\Control\Email\Email::is_valid_address() instead. */ 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); } } diff --git a/tests/php/ContentReviewNotificationTest.php b/tests/php/ContentReviewNotificationTest.php index 241dd9c..618de17 100644 --- a/tests/php/ContentReviewNotificationTest.php +++ b/tests/php/ContentReviewNotificationTest.php @@ -12,6 +12,7 @@ use SilverStripe\ContentReview\Extensions\ContentReviewOwner; use SilverStripe\ContentReview\Extensions\SiteTreeContentReview; use SilverStripe\ContentReview\Tasks\ContentReviewEmails; use SilverStripe\Control\HTTPRequest; +use SilverStripe\Dev\Deprecation; use SilverStripe\Dev\SapphireTest; use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\Security\Group; @@ -145,12 +146,14 @@ class ContentReviewNotificationTest extends SapphireTest $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'])); + Deprecation::withSuppressedNotice(function () use ($method, $task, $member) { + $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'])); + $this->assertFalse($method->invokeArgs($task, [null])); + $this->assertFalse($method->invokeArgs($task, ['broken.email'])); + $this->assertFalse($method->invokeArgs($task, ['broken@email'])); + }); } /**