From afd11d1f5e16217c31ba84de5c3cd7f5ff281563 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 21 Mar 2020 09:19:42 +1100 Subject: [PATCH] Use composer patches to apply CiviCRM customisations for pear_mail --- composer.json | 3 ++ composer.lock | 9 +++-- .../scripts/composer/patches/pear-mail.patch | 33 ------------------- tools/scripts/composer/pear-mail-fix.sh | 6 ---- 4 files changed, 10 insertions(+), 41 deletions(-) delete mode 100644 tools/scripts/composer/patches/pear-mail.patch diff --git a/composer.json b/composer.json index 005946c04f..9debce181a 100644 --- a/composer.json +++ b/composer.json @@ -244,6 +244,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/mail": { + "Apply CiviCRM Customisations for CRM-1367 and CRM-5946": "https://raw.githubusercontent.com/civicrm/civicrm-core/36319938a5bf26c1e7e2110a26a65db6a5979268/tools/scripts/composer/patches/pear-mail.patch" + }, "pear/net_smtp": { "Add in CiviCRM custom error message for CRM-8744": "https://raw.githubusercontent.com/civicrm/civicrm-core/a6a0ff13d2a155ad962529595dceaef728116f96/tools/scripts/composer/patches/net-smtp-patch.patch" }, diff --git a/composer.lock b/composer.lock index b6daf4ece7..4ec8844931 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3d22226af501e1f685b799acc269da69", + "content-hash": "9c8e8054f45d5bdd4e18f45701527d2b", "packages": [ { "name": "adrienrn/php-mimetyper", @@ -145,7 +145,7 @@ { "name": "Tobias Nyholm", "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" + "homepage": "https://github.com/Nyholm" }, { "name": "Nicolas Grekas", @@ -966,6 +966,11 @@ "pear/net_smtp": "Install optionally via your project's composer.json" }, "type": "library", + "extra": { + "patches_applied": { + "Apply CiviCRM Customisations for CRM-1367 and CRM-5946": "https://raw.githubusercontent.com/civicrm/civicrm-core/36319938a5bf26c1e7e2110a26a65db6a5979268/tools/scripts/composer/patches/pear-mail.patch" + } + }, "autoload": { "psr-0": { "Mail": "./" diff --git a/tools/scripts/composer/patches/pear-mail.patch b/tools/scripts/composer/patches/pear-mail.patch deleted file mode 100644 index 23fa638c9d..0000000000 --- a/tools/scripts/composer/patches/pear-mail.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff --git a/Mail.php b/Mail.php -index b04bc01..0e7da00 100644 ---- a/Mail.php -+++ b/Mail.php -@@ -155,6 +155,10 @@ class Mail - preg_replace('=((||0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i', - null, $value); - } -+ // fix for CRM-1367 -+ if (!array_key_exists('Date', $headers)) { -+ $headers['Date'] = date('r'); -+ } - } - - /** -diff --git a/Mail/mail.php b/Mail/mail.php -index ee1ecef..ae6e2e8 100644 ---- a/Mail/mail.php -+++ b/Mail/mail.php -@@ -145,7 +153,12 @@ class Mail_mail extends Mail { - if (is_a($headerElements, 'PEAR_Error')) { - return $headerElements; - } -- list(, $text_headers) = $headerElements; -+ list($from, $text_headers) = $headerElements; -+ // use Return-Path for SMTP envelope’s FROM address (if set), CRM-5946 -+ if (!empty($headers['Return-Path'])) { -+ $from = $headers['Return-Path']; -+ } -+ $this->_params = "-f".$from; - - // We only use mail()'s optional fifth parameter if the additional - // parameters have been provided and we're not running in safe mode. diff --git a/tools/scripts/composer/pear-mail-fix.sh b/tools/scripts/composer/pear-mail-fix.sh index 890dc617be..8bba016989 100755 --- a/tools/scripts/composer/pear-mail-fix.sh +++ b/tools/scripts/composer/pear-mail-fix.sh @@ -24,12 +24,6 @@ function safe_delete() { } -############################################################################## -# @fixme Extend pear/mail rather than patching it. -if ! grep -q 'CRM-1367' vendor/pear/mail/Mail.php; then - patch -d vendor/pear/mail -p1 < tools/scripts/composer/patches/pear-mail.patch.txt -fi - safe_delete vendor/pear/console_getopt/{package.xml,README.rst,tests} safe_delete vendor/pear/mail/{package.xml,README.rst,tests} safe_delete vendor/pear/pear-core-minimal/{package.xml,README.rst} -- 2.25.1