Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Horde_Mime to be unserialized from the previous version
Certain things (i.e. Alarms) have hard coded Horde_Mime serialized objects as the data storage. To work around these design decisions, it is necessary to put into the effort to allow that data to be upgraded instead of discarded
- Loading branch information
Showing
5 changed files
with
232 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
/** | ||
* Copyright 2015 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @category Horde | ||
* @copyright 2015 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @package Mime | ||
*/ | ||
|
||
/** | ||
* Upgrade V1 of MIME serialized data to V2. | ||
* | ||
* @author Michael Slusarz <slusarz@horde.org> | ||
* @category Horde | ||
* @copyright 2015 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @package Mime | ||
* @since 2.8.0 | ||
*/ | ||
class Horde_Mime_Part_Upgrade_V1 | ||
{ | ||
/** | ||
* Converted data. | ||
* | ||
* @var array | ||
*/ | ||
public $data = null; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param array $data V1 data. | ||
*/ | ||
public function __construct($data) | ||
{ | ||
// Version number | ||
array_shift($data); | ||
|
||
$d = array(); | ||
|
||
$type = array_shift($data); | ||
$subtype = array_shift($data); | ||
|
||
$ct = Horde_Mime_Headers_ContentParam_ContentType::create(); | ||
$d[4] = new Horde_Mime_Headers(); | ||
$d[4]->addHeaderOb($ct); | ||
$ct->setContentParamValue($type . '/' . $subtype); | ||
|
||
$d[9] = array_shift($data); | ||
|
||
if ($lang = array_shift($data)) { | ||
$d[4]->addHeaderOb( | ||
new Horde_Mime_Headers_ContentLanguage('', $lang) | ||
); | ||
} | ||
|
||
if ($cd = array_shift($data)) { | ||
$hdr = new Horde_Mime_Headers_ContentDescription(null, ''); | ||
$d[4]->addHeaderOb($hdr); | ||
$hdr->setValue($cd); | ||
} | ||
|
||
$cd = new Horde_Mime_Headers_ContentParam_ContentDisposition(null, ''); | ||
$d[4]->addHeaderOb($cd); | ||
$cd->setContentParamValue(array_shift($data)); | ||
|
||
foreach (array_shift($data) as $key => $val) { | ||
$cd[$key] = $val; | ||
} | ||
|
||
foreach (array_shift($data) as $key => $val) { | ||
$ct[$key] = $val; | ||
} | ||
|
||
$d[7] = array_shift($data); | ||
$d[6] = array_shift($data); | ||
$d[2] = array_shift($data); | ||
$d[5] = array_shift($data); | ||
|
||
if ($boundary = array_shift($data)) { | ||
$ct['boundary'] = $boundary; | ||
} | ||
|
||
$d[1] = array_shift($data); | ||
|
||
if ($cid = array_shift($data)) { | ||
$hdr = new Horde_Mime_Headers_ContentId(null, $cid); | ||
$d[4]->addHeaderOb($hdr); | ||
} | ||
|
||
if ($cd = array_shift($data)) { | ||
$hdr = new Horde_Mime_Headers_Element_Single('Content-Duration', ''); | ||
$d[4]->addHeaderOb($hdr); | ||
$hdr->setValue($cd); | ||
} | ||
|
||
$d[8] = 0; | ||
if (array_shift($data)) { | ||
$d[8] |= STATUS_REINDEX; | ||
} | ||
if (array_shift($data)) { | ||
$d[8] |= STATUS_BASEPART; | ||
} | ||
|
||
$d[3] = array_shift($data); | ||
|
||
if (count($data)) { | ||
$d[10] = reset($data); | ||
} | ||
|
||
$this->data = $d; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
QzoxNToiSG9yZGVfTWltZV9QYXJ0Ijo0NDQ6e2E6MjE6e2k6MDtpOjE7aToxO3M6NDoidGV4dCI7aToyO3M6NToicGxhaW4iO2k6MztzOjQ6IjdiaXQiO2k6NDthOjE6e2k6MDtzOjI6ImVuIjt9aTo1O3M6MzoiZm9vIjtpOjY7czoxMDoiYXR0YWNobWVudCI7aTo3O2E6Mjp7czozOiJmb28iO3M6MzoiYmFyIjtzOjg6ImZpbGVuYW1lIjtzOjM6ImZvbyI7fWk6ODthOjM6e3M6NDoibmFtZSI7czozOiJmb28iO3M6NzoiY2hhcnNldCI7czo4OiJ1cy1hc2NpaSI7czozOiJmb28iO3M6MzoiYmFyIjt9aTo5O2E6MDp7fWk6MTA7czoxOiIxIjtpOjExO3M6MToiCiI7aToxMjthOjE6e3M6MzoiZm9vIjtzOjM6ImJhciI7fWk6MTM7TjtpOjE0O047aToxNTtzOjQ1OiJzdmw4Q1Z0WkVFTzViZ3FSLXdGSUZROEBiaWd3b3JtLmN1cmVjYW50aS5vcmciO2k6MTY7aToxMDtpOjE3O2I6MDtpOjE4O2I6MDtpOjE5O047aToyMDtzOjM6ImZvbyI7fX0K |