Skip to content

Commit

Permalink
No need to copy the whole array, just flag the fact is't been validated.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed May 8, 2015
1 parent 450a212 commit 193ba47
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions framework/ActiveSync/lib/Horde/ActiveSync/Imap/MessageBodyData.php
Expand Up @@ -80,33 +80,33 @@ class Horde_ActiveSync_Imap_MessageBodyData

/**
*
* @var string
* @var arary
*/
protected $_plain;

/**
*
* @var string
* @var array
*/
protected $_html;

/**
*
* @var string
* @var array
*/
protected $_bodyPart;

/**
* Cached validated text/plain data.
* Flag to indicate self::$_Plain is validated.
*
* @var array
* @var boolean
*/
protected $_validatedPlain;

/**
* Cached validated text/html data
* Flag to indicate self::$_html is validated.
*
* @var array
* @var boolean
*/
protected $_validatedHtml;

Expand Down Expand Up @@ -138,6 +138,18 @@ public function __construct(array $params, array $options)
$this->_getParts();
}

public function __destruct()
{
$this->_basePart = null;
$this->_imap = null;
if (!empty($this->_plain) && ($this->_plain['body'] instanceof Horde_Stream)) {
$this->_plain['body'] = null;
}
if (!empty($this->_html) && ($this->_html['body'] instanceof Horde_Stream)) {
$this->_html['body'] = null;
}
}

public function &__get($property)
{
switch ($property) {
Expand Down Expand Up @@ -542,10 +554,10 @@ public function plainBody()
{
if (!empty($this->_plain) && empty($this->_validatedPlain)) {
$this->_validateBodyData($this->_plain);
$this->_validatedPlain = $this->_plain;
$this->_validatedPlain = true;
}
if ($this->_validatedPlain) {
return $this->_validatedPlain;
if ($this->_plain['body'] instanceof Horde_Stream) {
return $this->_plain;
}

return false;
Expand All @@ -564,10 +576,10 @@ public function htmlBody()
{
if (!empty($this->_html) && empty($this->_validatedHtml)) {
$this->_validateBodyData($this->_html);
$this->_validatedHtml = $this->_html;
$this->_validatedHtml = true;
}
if ($this->_validatedHtml) {
return $this->_validatedHtml;
if ($this->_html['body'] instanceof Horde_Stream) {
return $this->_html;
}

return false;
Expand Down

0 comments on commit 193ba47

Please sign in to comment.