Skip to content

Commit

Permalink
Use Horde_Pack
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Nov 4, 2013
1 parent e6c4fe4 commit d0e3996
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 81 deletions.
37 changes: 21 additions & 16 deletions imp/lib/Compose/Attachment.php
Expand Up @@ -213,28 +213,33 @@ public function serialize()
$this->storage;
}

return serialize(array(
'c' => $this->_composeCache,
'i' => $this->id,
'l' => $this->_linked,
'p' => $this->_part,
'r' => $this->related,
'u' => $this->_uuid
));
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->_composeCache,
$this->id,
$this->_linked,
$this->_part,
$this->related,
$this->_uuid
), array(
'compression' => false,
'phpob' => true
)
);
}

/**
*/
public function unserialize($data)
{
$data = @unserialize($data);

$this->_composeCache = $data['c'];
$this->id = $data['i'];
$this->_linked = $data['l'];
$this->_part = $data['p'];
$this->related = !empty($data['r']);
$this->_uuid = $data['u'];
list(
$this->_composeCache,
$this->id,
$this->_linked,
$this->_part,
$this->related,
$this->_uuid
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
}

}
24 changes: 13 additions & 11 deletions imp/lib/Flags.php
Expand Up @@ -391,23 +391,25 @@ public function offsetUnset($offset)
*/
public function serialize()
{
return serialize(array(
$this->_flags,
$this->_userflags
));
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->_flags,
$this->_userflags
), array(
'compression' => false,
'phpob' => true
)
);
}

/**
*/
public function unserialize($data)
{
$data = @unserialize($data);
if (!is_array($data)) {
throw new Exception('Cache invalidation.');
}

$this->_flags = $data[0];
$this->_userflags = $data[1];
list(
$this->_flags,
$this->_userflags
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
}

}
26 changes: 13 additions & 13 deletions imp/lib/Ftree.php
Expand Up @@ -873,28 +873,28 @@ public function count()
*/
public function serialize()
{
return serialize(array(
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(array(
$this->_accounts,
$this->_eltdiff,
json_encode(array(
$this->_elts,
$this->_parent
))
$this->_elts,
$this->_parent
), array(
'compress' => false,
'phpob' => true
));
}

/**
* @throws Exception
* @throws Horde_Pack_Exception
*/
public function unserialize($data)
{
$data = @unserialize($data);
if (!is_array($data)) {
throw new Exception('Cache version change');
}

list($this->_accounts, $this->_eltdiff, $json_data) = $data;
list($this->_elts, $this->_parent) = json_decode($json_data, true);
list(
$this->_accounts,
$this->_eltdiff,
$this->_elts,
$this->_parent
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
}

/**
Expand Down
16 changes: 11 additions & 5 deletions imp/lib/Ftree/Eltdiff.php
Expand Up @@ -177,10 +177,16 @@ public function clear()
*/
public function serialize()
{
return json_encode(array(
$this->track,
$this->_changes
));
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->track,
$this->_changes
),
array(
'compression' => false,
'phpob' => false
)
);
}

/**
Expand All @@ -190,7 +196,7 @@ public function unserialize($data)
list(
$this->track,
$this->_changes
) = json_decode($data, true);
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
}

}
18 changes: 12 additions & 6 deletions imp/lib/Imap.php
Expand Up @@ -895,11 +895,17 @@ static public function loadServerConfig($server = null)
*/
public function serialize()
{
return serialize(array(
$this->_ob,
$this->_id,
$this->_config
));
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->_ob,
$this->_id,
$this->_config
),
array(
'compression' => false,
'phpob' => true
)
);
}

/**
Expand All @@ -910,7 +916,7 @@ public function unserialize($data)
$this->_ob,
$this->_id,
$this->_config
) = unserialize($data);
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
}

}
14 changes: 10 additions & 4 deletions imp/lib/Imap/Config.php
Expand Up @@ -317,22 +317,28 @@ public function __unset($name)
*/
public function serialize()
{
global $session;
global $injector, $session;

if (!empty($this->_passwords)) {
$session->set('imp', self::PASSWORDS_KEY, $this->_passwords, $session::ENCRYPT);
}

return json_encode(array_filter($this->_config));
return $injector->getInstance('Horde_Pack')->pack(
array_filter($this->_config),
array(
'compression' => false,
'phpob' => false
)
);
}

/**
*/
public function unserialize($data)
{
global $session;
global $injector, $session;

$this->_config = json_decode($data, true);
$this->_config = $injector->getInstance('Horde_Pack')->unpack($data);

$this->_passwords = $session->get('imp', self::PASSWORDS_KEY, $session::TYPE_ARRAY);
}
Expand Down
16 changes: 11 additions & 5 deletions imp/lib/Mailbox.php
Expand Up @@ -1881,10 +1881,16 @@ protected function _onDelete($deleted)
*/
public function serialize()
{
return json_encode(array(
$this->_mbox,
$this->_cache
));
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
array(
$this->_mbox,
$this->_cache
),
array(
'compression' => false,
'phpob' => false
)
);
}

/**
Expand All @@ -1894,7 +1900,7 @@ public function unserialize($data)
list(
$this->_mbox,
$this->_cache
) = json_decode($data, true);
) = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
}

}
25 changes: 11 additions & 14 deletions imp/lib/Mailbox/List.php
Expand Up @@ -23,9 +23,6 @@
*/
class IMP_Mailbox_List implements ArrayAccess, Countable, Iterator, Serializable
{
/* Serialized version. */
const VERSION = 3;

/**
* Has the internal message list changed?
*
Expand Down Expand Up @@ -938,16 +935,21 @@ public function valid()
*/
public function serialize()
{
return serialize($this->_serialize());
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
$this->_serialize(),
array(
'compression' => false,
'phpob' => true
)
);
}

/**
*/
protected function _serialize()
{
$data = array(
'm' => $this->_mailbox,
'v' => self::VERSION
'm' => $this->_mailbox
);

if ($this->_buidmax) {
Expand Down Expand Up @@ -977,14 +979,9 @@ protected function _serialize()
*/
public function unserialize($data)
{
$data = @unserialize($data);
if (!is_array($data) ||
!isset($data['v']) ||
($data['v'] != self::VERSION)) {
throw new Exception('Cache version change');
}

$this->_unserialize($data);
$this->_unserialize(
$GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data)
);
}

/**
Expand Down
15 changes: 8 additions & 7 deletions imp/lib/Search.php
Expand Up @@ -552,7 +552,13 @@ public function getIterator()
*/
public function serialize()
{
return serialize($this->_search);
return $GLOBALS['injector']->getInstance('Horde_Pack')->pack(
$this->_search,
array(
'compression' => false,
'phpob' => true
)
);
}

/**
Expand All @@ -564,12 +570,7 @@ public function serialize()
*/
public function unserialize($data)
{
$data = @unserialize($data);
if (!is_array($data)) {
throw new Exception('Cache version change');
}

$this->_search = $data;
$this->_search = $GLOBALS['injector']->getInstance('Horde_Pack')->unpack($data);
}

}

0 comments on commit d0e3996

Please sign in to comment.