*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
*/
+$debug = false;
require_once dirname(__FILE__) . '/../../lib/Application.php';
Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true));
$rows = $ansel_db->queryAll($sql);
$update = $ansel_db->prepare('UPDATE ansel_shares SET attribute_style=? WHERE share_id=?;');
foreach ($rows as $row) {
+ // Make sure we haven't already migrated
+ if (@unserialize($row[1]) instanceof Ansel_Style) {
+ $cli->message('Skipping share ' . $row[0] . ', already migrated.', 'cli.message');
+ continue;
+ }
if (empty($styles[$row[1]])) {
$newStyle = '';
} else {
unset($properties['hide']);
$newStyle = serialize(new Ansel_Style($properties));
}
- $update->execute(array($newStyle, $row[0]));
+ if ($debug) {
+ $cli->message('Migrating share id: ' . $row[0] . ' from: ' . $row[1] . ' to: ' . $newStyle, 'cli.message');
+ }
+ $results = $update->execute(array($newStyle, $row[0]));
+ if ($results instanceof PEAR_Error) {
+ $cli->message($results->getMessage(), 'cli.error');
+ }
}
$cli->message('Gallery styles successfully migrated.', 'cli.success');