From a6a0ff13d2a155ad962529595dceaef728116f96 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 8 Feb 2020 14:40:42 +1100 Subject: [PATCH] [REF] Upgrade Net_SMTP Package and remove now unneded patches and move to using composer patches rather than patching in a script file --- composer.json | 5 ++- composer.lock | 31 ++++++++++++------- tools/scripts/composer/net-smtp-fix.sh | 16 ---------- ...et-smtp-patch.txt => net-smtp-patch.patch} | 16 +++++----- .../composer/patches/net-smtp-php7-patch.txt | 11 ------- .../composer/patches/net-smtp-ref-patch.txt | 22 ------------- .../composer/patches/net-smtp-tls-patch.txt | 23 -------------- 7 files changed, 30 insertions(+), 94 deletions(-) rename tools/scripts/composer/patches/{net-smtp-patch.txt => net-smtp-patch.patch} (57%) delete mode 100644 tools/scripts/composer/patches/net-smtp-php7-patch.txt delete mode 100644 tools/scripts/composer/patches/net-smtp-ref-patch.txt delete mode 100644 tools/scripts/composer/patches/net-smtp-tls-patch.txt diff --git a/composer.json b/composer.json index df799befb5..8bb5d61f13 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ "pear/validate_finance_creditcard": "dev-master", "civicrm/civicrm-cxn-rpc": "~0.19.01.08", "pear/auth_sasl": "1.1.0", - "pear/net_smtp": "1.6.*", + "pear/net_smtp": "1.9.*", "pear/net_socket": "1.0.*", "pear/mail": "^1.4", "civicrm/civicrm-setup": "~0.4.0", @@ -242,6 +242,9 @@ "Support PHPUnit 6+": "https://github.com/php-cache/integration-tests/commit/1ec7362962185df91d3d749bc3fa7e7b99cb9fc7.patch", "Add tests for binary data round trip": "https://github.com/php-cache/integration-tests/commit/89cd7068e83aa776774bfc44f6bcba858c085616.patch" }, + "pear/net_smtp": { + "Add in CiviCRM custom error message for CRM-8744": "tools/scripts/composer/patches/net-smtp-patch.patch" + }, "phpoffice/common": { "Fix handling of libxml_disable_entity_loader": "https://raw.githubusercontent.com/civicrm/civicrm-core/9d93748a36c7c5d44422911db1c98fb2f7067b34/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch" }, diff --git a/composer.lock b/composer.lock index c2c102f70b..a82aa24850 100644 --- a/composer.lock +++ b/composer.lock @@ -985,22 +985,22 @@ }, { "name": "pear/net_smtp", - "version": "1.6.3", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/pear/Net_SMTP.git", - "reference": "7b6240761adf6ee245098e238a25d5c35650d82c" + "reference": "f7fbc5808bfeba87c38e02ea4acc5243ffc9524e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pear/Net_SMTP/zipball/7b6240761adf6ee245098e238a25d5c35650d82c", - "reference": "7b6240761adf6ee245098e238a25d5c35650d82c", + "url": "https://api.github.com/repos/pear/Net_SMTP/zipball/f7fbc5808bfeba87c38e02ea4acc5243ffc9524e", + "reference": "f7fbc5808bfeba87c38e02ea4acc5243ffc9524e", "shasum": "" }, "require": { - "pear/net_socket": "*", - "pear/pear_exception": "*", - "php": ">=4.0.5" + "pear/net_socket": "@stable", + "pear/pear-core-minimal": "@stable", + "php": ">=5.4.0" }, "require-dev": { "phpunit/phpunit": "*" @@ -1009,6 +1009,11 @@ "pear/auth_sasl": "Install optionally via your project's composer.json" }, "type": "library", + "extra": { + "patches_applied": { + "Add in CiviCRM custom error message for CRM-8744": "tools/scripts/composer/patches/net-smtp-patch.patch" + } + }, "autoload": { "psr-0": { "Net": "./" @@ -1019,13 +1024,13 @@ "./" ], "license": [ - "PHP License" + "BSD-2-Clause" ], "authors": [ { "name": "Jon Parise", "email": "jon@php.net", - "homepage": "http://www.indelible.org", + "homepage": "https://www.indelible.org", "role": "Lead" }, { @@ -1035,13 +1040,13 @@ } ], "description": "An implementation of the SMTP protocol", - "homepage": "http://pear.github.io/Net_SMTP/", + "homepage": "https://pear.github.io/Net_SMTP/", "keywords": [ "email", "mail", "smtp" ], - "time": "2015-08-02T17:20:17+00:00" + "time": "2019-11-30T23:40:31+00:00" }, { "name": "pear/net_socket", @@ -2405,7 +2410,9 @@ "version": "3.0.0+php53", "dist": { "type": "zip", - "url": "https://github.com/tplaner/When/archive/c1ec099f421bff354cc5c929f83b94031423fc80.zip" + "url": "https://github.com/tplaner/When/archive/c1ec099f421bff354cc5c929f83b94031423fc80.zip", + "reference": null, + "shasum": null }, "require": { "php": ">=5.3.0" diff --git a/tools/scripts/composer/net-smtp-fix.sh b/tools/scripts/composer/net-smtp-fix.sh index aef79b3e30..de72c24a70 100755 --- a/tools/scripts/composer/net-smtp-fix.sh +++ b/tools/scripts/composer/net-smtp-fix.sh @@ -23,20 +23,4 @@ function safe_delete() { done } - -############################################################################## -# Add in CiviCRM custom error message for CRM-8744. -if ! grep -q 'CRM-8744' vendor/pear/net_smtp/Net/SMTP.php; then - patch vendor/pear/net_smtp/Net/SMTP.php < tools/scripts/composer/patches/net-smtp-patch.txt -fi -if ! grep -q '@STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT' vendor/pear/net_smtp/Net/SMTP.php; then - patch vendor/pear/net_smtp/Net/SMTP.php < tools/scripts/composer/patches/net-smtp-tls-patch.txt -fi -if ! grep -q 'function __construct' vendor/pear/net_smtp/Net/SMTP.php; then - patch vendor/pear/net_smtp/Net/SMTP.php < tools/scripts/composer/patches/net-smtp-php7-patch.txt -fi -if grep -q '&Auth_SASL::factory' vendor/pear/net_smtp/Net/SMTP.php; then - patch vendor/pear/net_smtp/Net/SMTP.php < tools/scripts/composer/patches/net-smtp-ref-patch.txt -fi - safe_delete vendor/pear/net_smtp/{README.rst,examples,phpdoc.sh,tests} diff --git a/tools/scripts/composer/patches/net-smtp-patch.txt b/tools/scripts/composer/patches/net-smtp-patch.patch similarity index 57% rename from tools/scripts/composer/patches/net-smtp-patch.txt rename to tools/scripts/composer/patches/net-smtp-patch.patch index 6b12048ca5..3a77c36792 100644 --- a/tools/scripts/composer/patches/net-smtp-patch.txt +++ b/tools/scripts/composer/patches/net-smtp-patch.patch @@ -1,15 +1,13 @@ ---- SMTP.php 2017-01-15 05:19:55.000000000 +1100 -+++ SMTP.php.new 2017-05-20 09:01:52.832373840 +1000 -@@ -368,8 +368,10 @@ +--- Net/SMTP.php 2019-12-01 10:40:31.000000000 +1100 ++++ Net/SMTP.php 2020-02-08 14:36:53.758318869 +1100 +@@ -376,7 +376,9 @@ return true; } - -- return PEAR::raiseError('Invalid response code received from server', -- $this->_code, PEAR_ERROR_RETURN); + +- return PEAR::raiseError('Invalid response code received from server', $this->code); + // CRM-8744 + $errorMessage = 'Invalid response code received from SMTP server while sending email. This is often caused by a misconfiguration in Outbound Email settings. Please verify the settings at Administer CiviCRM >> Global Settings >> Outbound Email (SMTP).'; -+ return PEAR::raiseError($errorMessage, $this->_code, PEAR_ERROR_RETURN); -+ ++ return PEAR::raiseError($errorMessage, $this->code, PEAR_ERROR_RETURN); } - + /** diff --git a/tools/scripts/composer/patches/net-smtp-php7-patch.txt b/tools/scripts/composer/patches/net-smtp-php7-patch.txt deleted file mode 100644 index 6ed1605c04..0000000000 --- a/tools/scripts/composer/patches/net-smtp-php7-patch.txt +++ /dev/null @@ -1,11 +0,0 @@ ---- SMTP.php 2017-05-20 11:50:53.716664059 +1000 -+++ SMTP.php.new 2017-05-20 12:38:36.271530119 +1000 -@@ -167,7 +167,7 @@ - * @access public - * @since 1.0 - */ -- function Net_SMTP($host = null, $port = null, $localhost = null, -+ function __construct($host = null, $port = null, $localhost = null, - $pipelining = false, $timeout = 0, $socket_options = null) - { - if (isset($host)) { diff --git a/tools/scripts/composer/patches/net-smtp-ref-patch.txt b/tools/scripts/composer/patches/net-smtp-ref-patch.txt deleted file mode 100644 index 84f080d19e..0000000000 --- a/tools/scripts/composer/patches/net-smtp-ref-patch.txt +++ /dev/null @@ -1,22 +0,0 @@ ---- SMTP.php 2017-06-15 20:08:34.696988543 -0700 -+++ SMTP.php.new 2017-06-15 20:08:25.951703778 -0700 -@@ -732,7 +732,8 @@ - } - - $challenge = base64_decode($this->_arguments[0]); -- $digest = &Auth_SASL::factory('digest-md5'); -+ // CRM-8597 -+ $digest = Auth_SASL::factory('digest-md5'); - $auth_str = base64_encode($digest->getResponse($uid, $pwd, $challenge, - $this->host, "smtp", - $authz)); -@@ -784,7 +785,8 @@ - } - - $challenge = base64_decode($this->_arguments[0]); -- $cram = &Auth_SASL::factory('cram-md5'); -+ // CRM-8597 -+ $cram = Auth_SASL::factory('cram-md5'); - $auth_str = base64_encode($cram->getResponse($uid, $pwd, $challenge)); - - if (PEAR::isError($error = $this->_put($auth_str))) { diff --git a/tools/scripts/composer/patches/net-smtp-tls-patch.txt b/tools/scripts/composer/patches/net-smtp-tls-patch.txt deleted file mode 100644 index 3eb2122b05..0000000000 --- a/tools/scripts/composer/patches/net-smtp-tls-patch.txt +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/Net/SMTP.php b/Net/SMTP.php -index 28eae8c..8f4e92b 100644 ---- a/Net/SMTP.php -+++ b/Net/SMTP.php -@@ -602,7 +602,17 @@ - if (PEAR::isError($result = $this->_parseResponse(220))) { - return $result; - } -- if (PEAR::isError($result = $this->_socket->enableCrypto(true, STREAM_CRYPTO_METHOD_TLS_CLIENT))) { -+ if (isset($this->_socket_options['ssl']['crypto_method'])) { -+ $crypto_method = $this->_socket_options['ssl']['crypto_method']; -+ } else { -+ /* STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT constant does not exist -+ * and STREAM_CRYPTO_METHOD_SSLv23_CLIENT constant is -+ * inconsistent across PHP versions. */ -+ $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT -+ | @STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT -+ | @STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; -+ } -+ if (PEAR::isError($result = $this->_socket->enableCrypto(true, $crypto_method))) { - return $result; - } elseif ($result !== true) { - return PEAR::raiseError('STARTTLS failed'); -- 2.25.1