catch statement exceptions when truncating columns
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 30 Jul 2014 13:23:38 +0000 (15:23 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 30 Jul 2014 14:10:02 +0000 (16:10 +0200)
... as they might no longer exist

Change-Id: I99ce44aeb86a5e1f50b2d58a45d22c4b5422574e
Reviewed-on: http://gerrit.tine20.com/customers/914
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Reviewed-by: Michael Spahn <m.spahn@metaways.de>
Tested-by: Jenkins CI (http://ci.tine20.com/)
tine20/Setup/Update/Abstract.php

index 3676f61..82bc1e2 100644 (file)
@@ -5,7 +5,7 @@
  * @package     Setup
  * @subpackage  Update
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
- * @copyright   Copyright (c) 2007-2012 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2007-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Matthias Greiling <m.greiling@metaways.de>
  */
 
@@ -318,21 +318,26 @@ class Setup_Update_Abstract
     {
         foreach ($columns as $table => $fields) {
             foreach ($fields as $field => $config) {
-                
-                $this->shortenTextValues($table, $field, $length);
-                if (isset($config)) {
-                    $config = ($config == 'null' ? '<default>NULL</default>': '<notnull>' . $config . '</notnull>');
+                try {
+                    $this->shortenTextValues($table, $field, $length);
+                    if (isset($config)) {
+                        $config = ($config == 'null' ? '<default>NULL</default>': '<notnull>' . $config . '</notnull>');
+                    }
+                    $declaration = new Setup_Backend_Schema_Field_Xml('
+                        <field>
+                            <name>' . $field . '</name>
+                            <type>text</type>
+                            <length>' . $length . '</length>'
+                            . $config .
+                        '</field>
+                    ');
+                    
+                    $this->_backend->alterCol($table, $declaration);
+                } catch (Zend_Db_Statement_Exception $zdse) {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ 
+                        . ' Could not truncate text column ' . $field . ' in table ' . $table);
+                    Tinebase_Exception::log($zdse);
                 }
-                $declaration = new Setup_Backend_Schema_Field_Xml('
-                    <field>
-                        <name>' . $field . '</name>
-                        <type>text</type>
-                        <length>' . $length . '</length>'
-                        . $config .
-                    '</field>
-                ');
-                
-                $this->_backend->alterCol($table, $declaration);
             }
         }
     }