From: Michael J. Rubinsky Date: Thu, 23 Sep 2010 16:30:01 +0000 (-0400) Subject: Add debug output, check for previously run migration. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=49bbd79fb9feb4e52481c4fab0ad2129b6a34642;p=horde.git Add debug output, check for previously run migration. Set $debug = true at the top of the file to get some debug output. Script will skip any shares that look like they have already been migrated also. --- diff --git a/ansel/scripts/upgrades/2010-09-16_migrate_styles.php b/ansel/scripts/upgrades/2010-09-16_migrate_styles.php index c43b589a4..4912ea641 100644 --- a/ansel/scripts/upgrades/2010-09-16_migrate_styles.php +++ b/ansel/scripts/upgrades/2010-09-16_migrate_styles.php @@ -7,6 +7,7 @@ * * @author Michael J. Rubinsky */ +$debug = false; require_once dirname(__FILE__) . '/../../lib/Application.php'; Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); @@ -30,6 +31,11 @@ $defaults = array( $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 { @@ -40,6 +46,12 @@ foreach ($rows as $row) { 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');