Index: branches/5.2.x/core/units/helpers/deployment_helper.php =================================================================== diff -u -N -r15856 -r16019 --- branches/5.2.x/core/units/helpers/deployment_helper.php (.../deployment_helper.php) (revision 15856) +++ branches/5.2.x/core/units/helpers/deployment_helper.php (.../deployment_helper.php) (revision 16019) @@ -1,6 +1,6 @@ dryRun ) { - $this->exportLanguagePack(); + try { + if ( $this->dryRun ) { + $this->exportLanguagePack(); + } + else { + $this->importLanguagePack(); + } } - else { - $this->importLanguagePack(); + catch ( Exception $e ) { + echo $this->colorText('Failed with Module "' . $module_name . '".', 'red', true) . PHP_EOL . PHP_EOL; + + return false; } echo $this->colorText('Done with Module "' . $module_name . '".', 'green', true) . PHP_EOL . PHP_EOL; @@ -490,33 +497,33 @@ $sqls = explode(";\n", $no_comment_sqls . "\n"); // ensures that last sql won't have ";" in it $sqls = array_map('trim', $sqls); - foreach ($sqls as $sql) { - if ( substr($sql, 0, 1) == '#' ) { - // output comment as is - $this->toLog($sql); - echo $this->colorText($sql, 'purple') . PHP_EOL; - continue; - } - elseif ( $sql ) { - $this->toLog($sql . ' ... ', false); - $escaped_sql = $this->isCommandLine ? $sql : kUtil::escape($sql); - echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', $escaped_sql)), 0, self::SQL_TRIM_LENGTH) . ' ... '; + try { + foreach ($sqls as $sql) { + if ( substr($sql, 0, 1) == '#' ) { + // output comment as is + $this->toLog($sql); + echo $this->colorText($sql, 'purple') . PHP_EOL; + continue; + } + elseif ( $sql ) { + $this->toLog($sql . ' ... ', false); + $escaped_sql = $this->isCommandLine ? $sql : kUtil::escape($sql); + echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', $escaped_sql)), 0, self::SQL_TRIM_LENGTH) . ' ... '; - $this->Conn->Query($sql); + $this->Conn->Query($sql); - if ( $this->Conn->hasError() ) { - // consider revisions with errors applied - $this->appliedRevisions[] = $revision; - - return false; - } - else { $this->toLog('OK (' . $this->Conn->getAffectedRows() . ')'); $this->displayStatus('OK (' . $this->Conn->getAffectedRows() . ')'); } } } + catch (Exception $e) { + // consider revisions with errors applied + $this->appliedRevisions[] = $revision; + return false; + } + $this->appliedRevisions[] = $revision; } @@ -526,13 +533,14 @@ } /** - * Error handler for sql errors + * Error handler for sql errors. * - * @param int $code - * @param string $msg - * @param string $sql - * @return bool - * @access public + * @param integer $code Error code. + * @param string $msg Error message. + * @param string $sql SQL query. + * + * @return void + * @throws Exception When SQL error happens. */ public function handleSqlError($code, $msg, $sql) { @@ -541,7 +549,7 @@ $this->displayStatus('FAILED' . PHP_EOL . 'SQL Error #' . $code . ': ' . $msg); $this->out('Please execute rest of SQLs in this Revision by hand and run deployment script again.', true); - return true; + throw new Exception($msg, $code); } /** @@ -678,4 +686,4 @@ echo $text . ($new_line ? PHP_EOL : ''); } -} \ No newline at end of file +}