From e24fb3f86c745d0b9e1af97e54037640e0a74e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20B=C3=BCnte?= Date: Mon, 30 May 2022 05:04:51 +0200 Subject: [PATCH 1/4] Fix i18nTextCollector produces corrupt output / namespaces when running under PHP8.0 (#10228) * FIX i18nTextCollector produces corrupt output / namespaces when running under PHP8.0 --- src/i18n/TextCollection/i18nTextCollector.php | 9 +-------- tests/php/i18n/i18nTextCollectorTest.php | 8 +++++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/i18n/TextCollection/i18nTextCollector.php b/src/i18n/TextCollection/i18nTextCollector.php index b95bde50d95..e7d5e95fb15 100644 --- a/src/i18n/TextCollection/i18nTextCollector.php +++ b/src/i18n/TextCollection/i18nTextCollector.php @@ -571,20 +571,13 @@ public function collectFromCode($content, $fileName, Module $module) if (is_array($token)) { list($id, $text) = $token; - // PHP 8 namespace tokens - if (\defined('T_NAME_QUALIFIED') && in_array($id, [T_NAME_FULLY_QUALIFIED, T_NAME_QUALIFIED])) { - $inNamespace = true; - $currentClass[] = $text; - continue; - } - // Check class if ($id === T_NAMESPACE) { $inNamespace = true; $currentClass = []; continue; } - if ($inNamespace && $id === T_STRING) { + if ($inNamespace && ($id === T_STRING || (defined('T_NAME_QUALIFIED') && $id === T_NAME_QUALIFIED))) { $currentClass[] = $text; continue; } diff --git a/tests/php/i18n/i18nTextCollectorTest.php b/tests/php/i18n/i18nTextCollectorTest.php index e9d22805a05..6812c9cc6fe 100644 --- a/tests/php/i18n/i18nTextCollectorTest.php +++ b/tests/php/i18n/i18nTextCollectorTest.php @@ -300,9 +300,14 @@ public function testCollectFromCodeNamespace() assertEquals( [ 'SilverStripe\\Framework\\Core\\MyClass.NEWLINES' => "New Lines", From 96a931d24fba891ce5c01f2902e9587e683a9714 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 6 Oct 2022 09:52:06 +1300 Subject: [PATCH 2/4] API Deprecate swiftmailer --- src/Control/Email/Email.php | 34 +++++++++++++++++++++++++++++++ src/Control/Email/Mailer.php | 3 +++ src/Control/Email/SwiftMailer.php | 2 ++ src/Control/Email/SwiftPlugin.php | 3 +++ 4 files changed, 42 insertions(+) diff --git a/src/Control/Email/Email.php b/src/Control/Email/Email.php index b2fcf07fa28..5fbd200399e 100644 --- a/src/Control/Email/Email.php +++ b/src/Control/Email/Email.php @@ -11,6 +11,7 @@ use SilverStripe\Core\Convert; use SilverStripe\Core\Environment; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\Deprecation; use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBField; use SilverStripe\ORM\FieldType\DBHTMLText; @@ -256,10 +257,13 @@ public function __construct( } /** + * @deprecated 4.12.0 Will be removed without equivalent functionality to replace it + * * @return Swift_Message */ public function getSwiftMessage() { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); if (!$this->swiftMessage) { $message = new Swift_Message(null, null, 'text/html', 'utf-8'); // Set priority to fix PHP 8.1 SimpleMessage::getPriority() sscanf() null parameter @@ -271,12 +275,15 @@ public function getSwiftMessage() } /** + * @deprecated 4.12.0 Will be removed without equivalent functionality to replace it + * * @param Swift_Message $swiftMessage * * @return $this */ public function setSwiftMessage($swiftMessage) { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); $dateTime = new DateTime(); $dateTime->setTimestamp(DBDatetime::now()->getTimestamp()); $swiftMessage->setDate($dateTime); @@ -706,30 +713,39 @@ public function setBody($body) } /** + * @deprecated 4.12.0 Will be replaced with html() + * * @return $this */ public function invalidateBody() { + Deprecation::notice('4.12.0', 'Will be replaced with html()'); $this->setBody(null); return $this; } /** + * @deprecated 4.12.0 Will be replaced with getData() + * * @return string The base URL for the email */ public function BaseURL() { + Deprecation::notice('4.12.0', 'Will be replaced with getData()'); return Director::absoluteBaseURL(); } /** + * @deprecated Will be removed without equivalent functionality to replace it + * * Debugging help * * @return string Debug info */ public function debug() { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); $this->render(); $class = static::class; @@ -794,31 +810,40 @@ public function setPlainTemplate($template) } /** + * @deprecated 4.12.0 Will be removed without equivalent functionality to replace it + * * @param array $recipients * @return $this */ public function setFailedRecipients($recipients) { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); $this->failedRecipients = $recipients; return $this; } /** + * @deprecated 4.12.0 Will be removed without equivalent functionality to replace it + * * @return array */ public function getFailedRecipients() { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); return $this->failedRecipients; } /** + * @deprecated 4.12.0 Will be replaced with getData() + * * Used by {@link SSViewer} templates to detect if we're rendering an email template rather than a page template * * @return bool */ public function IsEmail() { + Deprecation::notice('4.12.0', 'Will be replaced with getData()'); return true; } @@ -920,10 +945,13 @@ public function render($plainOnly = false) } /** + * @deprecated 4.12.0 Will be removed without equivalent functionality to replace it + * * @return Swift_MimePart|false */ public function findPlainPart() { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); foreach ($this->getSwiftMessage()->getChildren() as $child) { if ($child instanceof Swift_MimePart && $child->getContentType() == 'text/plain') { return $child; @@ -933,10 +961,13 @@ public function findPlainPart() } /** + * @deprecated 4.12.0 Will be removed without equivalent functionality to replace it + * * @return bool */ public function hasPlainPart() { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); if ($this->getSwiftMessage()->getContentType() === 'text/plain') { return true; } @@ -944,12 +975,15 @@ public function hasPlainPart() } /** + * @deprecated 4.12.0 Will be removed without equivalent functionality to replace it + * * Automatically adds a plain part to the email generated from the current Body * * @return $this */ public function generatePlainPartFromBody() { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); $plainPart = $this->findPlainPart(); if ($plainPart) { $this->getSwiftMessage()->detach($plainPart); diff --git a/src/Control/Email/Mailer.php b/src/Control/Email/Mailer.php index b661c91b8db..e90342bb86a 100644 --- a/src/Control/Email/Mailer.php +++ b/src/Control/Email/Mailer.php @@ -2,6 +2,9 @@ namespace SilverStripe\Control\Email; +/** + * @deprecated 4.12.0 Will be replaced with symfony/mailer + */ interface Mailer { diff --git a/src/Control/Email/SwiftMailer.php b/src/Control/Email/SwiftMailer.php index 1bed67c6f09..5dde0809f1d 100644 --- a/src/Control/Email/SwiftMailer.php +++ b/src/Control/Email/SwiftMailer.php @@ -9,6 +9,8 @@ use Swift_Message; /** + * @deprecated 4.12.0 Will be replaced with symfony/mailer + * * Mailer objects are responsible for actually sending emails. * The default Mailer class will use PHP's mail() function. */ diff --git a/src/Control/Email/SwiftPlugin.php b/src/Control/Email/SwiftPlugin.php index cccc47ce91f..ea9e0aa812f 100644 --- a/src/Control/Email/SwiftPlugin.php +++ b/src/Control/Email/SwiftPlugin.php @@ -2,6 +2,9 @@ namespace SilverStripe\Control\Email; +/** + * @deprecated 4.12.0 Will be replaced with symfony/mailer + */ class SwiftPlugin implements \Swift_Events_SendListener { /** From dd5b39e6b8d74c62575601039090b1187c18d8d0 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Thu, 6 Oct 2022 14:40:57 +1300 Subject: [PATCH 3/4] MNT Don't use deprecated jQuery size() function in behat (#10524) --- tests/behat/src/CmsUiContext.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/behat/src/CmsUiContext.php b/tests/behat/src/CmsUiContext.php index 1b861a33d41..62504e63b7f 100644 --- a/tests/behat/src/CmsUiContext.php +++ b/tests/behat/src/CmsUiContext.php @@ -141,7 +141,7 @@ protected function getCmsTabsElement() { $this->getSession()->wait( 5000, - "window.jQuery && window.jQuery('.cms-content-header-tabs').size() > 0" + "window.jQuery && window.jQuery('.cms-content-header-tabs').length > 0" ); $page = $this->getSession()->getPage(); @@ -155,8 +155,8 @@ protected function getCmsContentToolbarElement() { $this->getSession()->wait( 5000, - "window.jQuery && window.jQuery('.cms-content-toolbar').size() > 0 " - . "&& window.jQuery('.cms-content-toolbar').children().size() > 0" + "window.jQuery && window.jQuery('.cms-content-toolbar').length > 0 " + . "&& window.jQuery('.cms-content-toolbar').children().length > 0" ); $page = $this->getSession()->getPage(); @@ -170,7 +170,7 @@ protected function getCmsTreeElement() { $this->getSession()->wait( 5000, - "window.jQuery && window.jQuery('.cms-tree').size() > 0" + "window.jQuery && window.jQuery('.cms-tree').length > 0" ); $page = $this->getSession()->getPage(); @@ -281,7 +281,7 @@ public function stepIClickOnElementInTheContextMenu($method, $link) // Wait until context menu has appeared $this->getSession()->wait( 1000, - "window.jQuery && window.jQuery('.jstree-apple-context').size() > 0" + "window.jQuery && window.jQuery('.jstree-apple-context').length > 0" ); $regionObj = $context->getRegionObj('.jstree-apple-context'); Assert::assertNotNull($regionObj, "Context menu could not be found"); @@ -448,7 +448,7 @@ public function iShouldSeeACmsTab($negate, $tab) { $this->getSession()->wait( 5000, - "window.jQuery && window.jQuery('.ui-tabs-nav').size() > 0" + "window.jQuery && window.jQuery('.ui-tabs-nav').length > 0" ); $page = $this->getSession()->getPage(); @@ -477,7 +477,7 @@ public function iClickTheCmsTab($tab) { $this->getSession()->wait( 5000, - "window.jQuery && window.jQuery('.ui-tabs-nav').size() > 0" + "window.jQuery && window.jQuery('.ui-tabs-nav').length > 0" ); $page = $this->getSession()->getPage(); From 906cd0e76d79d3cbcc7a2e25500bf1c8d561a431 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Fri, 7 Oct 2022 14:44:02 +1300 Subject: [PATCH 4/4] API Deprecate render() (#10527) --- src/Control/Email/Email.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Control/Email/Email.php b/src/Control/Email/Email.php index 5fbd200399e..d6eb96801dc 100644 --- a/src/Control/Email/Email.php +++ b/src/Control/Email/Email.php @@ -875,12 +875,16 @@ public function sendPlain() } /** + * @deprecated 4.12.0 Will be removed without equivalent functionality to replace it + * * Render the email * @param bool $plainOnly Only render the message as plain text * @return $this */ public function render($plainOnly = false) { + Deprecation::notice('4.12.0', 'Will be removed without equivalent functionality to replace it'); + if ($existingPlainPart = $this->findPlainPart()) { $this->getSwiftMessage()->detach($existingPlainPart); }