From 9372e3f98ada1ffa01dc570361a983b7292f8ce7 Mon Sep 17 00:00:00 2001 From: Lars Moelleken Date: Thu, 10 Dec 2015 12:44:10 +0100 Subject: [PATCH] Revert "[!]: update for performance (need some testing) v2" This reverts commit e1df8bc991a0d189d87e64e3640ebd74144768d2. --- lib/classes/Swift.php | 1 - lib/classes/Swift/Encoder/QpEncoder.php | 4 +-- lib/classes/Swift/Encoder/Rfc2231Encoder.php | 4 +-- lib/classes/Swift/KeyCache/ArrayKeyCache.php | 2 -- lib/classes/Swift/MemorySpool.php | 8 +---- lib/classes/Swift/Message.php | 14 ++++---- .../ContentEncoder/QpContentEncoderProxy.php | 6 ++-- .../Swift/Mime/SimpleHeaderFactory.php | 6 ++-- lib/classes/Swift/Mime/SimpleHeaderSet.php | 10 +++--- lib/classes/Swift/Mime/SimpleMimeEntity.php | 34 ++++++++----------- lib/classes/Swift/SpoolTransport.php | 3 +- 11 files changed, 33 insertions(+), 59 deletions(-) diff --git a/lib/classes/Swift.php b/lib/classes/Swift.php index af204725c..ca016c58c 100644 --- a/lib/classes/Swift.php +++ b/lib/classes/Swift.php @@ -19,7 +19,6 @@ abstract class Swift const VERSION = '5.x'; public static $initialized = false; - public static $useMemorySpool = false; public static $inits = array(); /** diff --git a/lib/classes/Swift/Encoder/QpEncoder.php b/lib/classes/Swift/Encoder/QpEncoder.php index 2e8580f1e..a33d742cc 100644 --- a/lib/classes/Swift/Encoder/QpEncoder.php +++ b/lib/classes/Swift/Encoder/QpEncoder.php @@ -301,8 +301,6 @@ protected function _standardize($string) */ public function __clone() { - if (true === Swift::$useMemorySpool) { - $this->_charStream = clone $this->_charStream; - } + $this->_charStream = clone $this->_charStream; } } diff --git a/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/lib/classes/Swift/Encoder/Rfc2231Encoder.php index d8fb811fa..057428a37 100644 --- a/lib/classes/Swift/Encoder/Rfc2231Encoder.php +++ b/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -90,8 +90,6 @@ public function charsetChanged($charset) */ public function __clone() { - if (true === Swift::$useMemorySpool) { - $this->_charStream = clone $this->_charStream; - } + $this->_charStream = clone $this->_charStream; } } diff --git a/lib/classes/Swift/KeyCache/ArrayKeyCache.php b/lib/classes/Swift/KeyCache/ArrayKeyCache.php index dcf7a0d37..262951b89 100644 --- a/lib/classes/Swift/KeyCache/ArrayKeyCache.php +++ b/lib/classes/Swift/KeyCache/ArrayKeyCache.php @@ -120,11 +120,9 @@ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $o public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) { $is = clone $this->_stream; - $is->setKeyCache($this); $is->setNsKey($nsKey); $is->setItemKey($itemKey); - if (isset($writeThrough)) { $is->setWriteThroughStream($writeThrough); } diff --git a/lib/classes/Swift/MemorySpool.php b/lib/classes/Swift/MemorySpool.php index 0fcc08719..5b239694d 100644 --- a/lib/classes/Swift/MemorySpool.php +++ b/lib/classes/Swift/MemorySpool.php @@ -17,12 +17,6 @@ class Swift_MemorySpool implements Swift_Spool { protected $messages = array(); - public function __construct() - { - Swift::$useMemorySpool = true; - } - - /** * Tests if this Transport mechanism has started. * @@ -56,7 +50,7 @@ public function stop() */ public function queueMessage(Swift_Mime_Message $message) { - // clone the message to make sure it is not changed while in the queue + //clone the message to make sure it is not changed while in the queue $this->messages[] = clone $message; return true; diff --git a/lib/classes/Swift/Message.php b/lib/classes/Swift/Message.php index 98cb8107d..b63ad9af6 100644 --- a/lib/classes/Swift/Message.php +++ b/lib/classes/Swift/Message.php @@ -287,16 +287,14 @@ protected function restoreMessage() */ public function __clone() { - if (true === Swift::$useMemorySpool) { - parent::__clone(); + parent::__clone(); - foreach ($this->bodySigners as $key => $bodySigner) { - $this->bodySigners[$key] = clone($bodySigner); - } + foreach ($this->bodySigners as $key => $bodySigner) { + $this->bodySigners[$key] = clone($bodySigner); + } - foreach ($this->headerSigners as $key => $headerSigner) { - $this->headerSigners[$key] = clone($headerSigner); - } + foreach ($this->headerSigners as $key => $headerSigner) { + $this->headerSigners[$key] = clone($headerSigner); } } } diff --git a/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php index 5e06a6090..3214e1cf3 100644 --- a/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php +++ b/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -51,10 +51,8 @@ public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEnco */ public function __clone() { - if (true === Swift::$useMemorySpool) { - $this->safeEncoder = clone $this->safeEncoder; - $this->nativeEncoder = clone $this->nativeEncoder; - } + $this->safeEncoder = clone $this->safeEncoder; + $this->nativeEncoder = clone $this->nativeEncoder; } /** diff --git a/lib/classes/Swift/Mime/SimpleHeaderFactory.php b/lib/classes/Swift/Mime/SimpleHeaderFactory.php index 16f21d5eb..f2c158c8c 100644 --- a/lib/classes/Swift/Mime/SimpleHeaderFactory.php +++ b/lib/classes/Swift/Mime/SimpleHeaderFactory.php @@ -197,10 +197,8 @@ public function charsetChanged($charset) */ public function __clone() { - if (true === Swift::$useMemorySpool) { - $this->_encoder = clone $this->_encoder; - $this->_paramEncoder = clone $this->_paramEncoder; - } + $this->_encoder = clone $this->_encoder; + $this->_paramEncoder = clone $this->_paramEncoder; } /** diff --git a/lib/classes/Swift/Mime/SimpleHeaderSet.php b/lib/classes/Swift/Mime/SimpleHeaderSet.php index 020e8928b..adf302a54 100644 --- a/lib/classes/Swift/Mime/SimpleHeaderSet.php +++ b/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -446,13 +446,11 @@ private function _notifyHeadersOfCharset($charset) */ public function __clone() { - if (true === Swift::$useMemorySpool) { - $this->_factory = clone $this->_factory; + $this->_factory = clone $this->_factory; - foreach ($this->_headers as $groupKey => $headerGroup) { - foreach ($headerGroup as $key => $header) { - $this->_headers[$groupKey][$key] = clone $header; - } + foreach ($this->_headers as $groupKey => $headerGroup) { + foreach ($headerGroup as $key => $header) { + $this->_headers[$groupKey][$key] = clone $header; } } } diff --git a/lib/classes/Swift/Mime/SimpleMimeEntity.php b/lib/classes/Swift/Mime/SimpleMimeEntity.php index c6c0362a7..f3193bfd3 100644 --- a/lib/classes/Swift/Mime/SimpleMimeEntity.php +++ b/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -957,27 +957,21 @@ private function _assertValidId($id) */ public function __clone() { - if (true === Swift::$useMemorySpool) { - $this->_headers = clone $this->_headers; - $this->_encoder = clone $this->_encoder; - - // TODO? do we need this ? -> https://github.com/bmurashin/swiftmailer/commit/ef5c5134e6e02afc2e8ff3287bfa74be1b33dcaf - //$this->_cacheKey = $this->_generateNewCacheKey(); - //$this->generateId(); - - $children = array(); - foreach ($this->_children as $pos => $child) { - if ( - $child instanceof Swift_Mime_Attachment - || - $child instanceof Swift_Mime_EmbeddedFile - ) { - $children[$pos] = $child; - } else { - $children[$pos] = clone $child; - } + $this->_headers = clone $this->_headers; + $this->_encoder = clone $this->_encoder; + + // TODO? do we need this ? -> https://github.com/bmurashin/swiftmailer/commit/ef5c5134e6e02afc2e8ff3287bfa74be1b33dcaf + //$this->_cacheKey = $this->_generateNewCacheKey(); + //$this->generateId(); + + $children = array(); + foreach ($this->_children as $pos => $child) { + if ($child instanceof Swift_Mime_Attachment || $child instanceof Swift_Mime_EmbeddedFile) { + $children[$pos] = $child; + } else { + $children[$pos] = clone $child; } - $this->setChildren($children); } + $this->setChildren($children); } } diff --git a/lib/classes/Swift/SpoolTransport.php b/lib/classes/Swift/SpoolTransport.php index bca774031..cf9bf78fb 100644 --- a/lib/classes/Swift/SpoolTransport.php +++ b/lib/classes/Swift/SpoolTransport.php @@ -22,7 +22,8 @@ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport */ public function __construct(Swift_Spool $spool) { - $arguments = Swift_DependencyContainer::getInstance()->createDependenciesFor('transport.spool'); + $arguments = Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.spool'); $arguments[] = $spool;