[Cs-webdbupgrade-commits] SF.net SVN: cs-webdbupgrade:[17] trunk/0.1/cs_webdbupgrade.class.php
Status: Inactive
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-07-27 17:24:36
|
Revision: 17 http://cs-webdbupgrade.svn.sourceforge.net/cs-webdbupgrade/?rev=17&view=rev Author: crazedsanity Date: 2009-07-27 17:24:28 +0000 (Mon, 27 Jul 2009) Log Message: ----------- Added a try/catch block to try to fix MySQL problems (see issue #282) /cs_webdbupgrade.class.php: * perform_upgrade(): -- log info from check_for_version_conflict() as 'info' -- use a try/catch block: commit as normal, rollaback on excpetion. * check_for_version_conflict(): -- remove logging (avoids dupe entries). * do_single_upgrade(): -- log the final outcome as 'system' instead of the default 'error' Modified Paths: -------------- trunk/0.1/cs_webdbupgrade.class.php Modified: trunk/0.1/cs_webdbupgrade.class.php =================================================================== --- trunk/0.1/cs_webdbupgrade.class.php 2009-07-24 14:55:09 UTC (rev 16) +++ trunk/0.1/cs_webdbupgrade.class.php 2009-07-27 17:24:28 UTC (rev 17) @@ -269,35 +269,47 @@ $this->get_database_version(); //check for version conflicts. - $this->check_for_version_conflict(); + $versionConflictInfo = $this->check_for_version_conflict(); + + if($versionConflictInfo !== false) { + $this->logsObj->log_by_class("Upgrading ". $versionConflictInfo ." versions, from " . + "(". $this->databaseVersion .") to (". $this->versionFileVersion .")", 'info'); + } + $upgradeList = $this->get_upgrade_list(); - $i=0; - $this->logsObj->log_by_class(__METHOD__ .": starting to run through the upgrade list, starting at (". $this->databaseVersion .")...", 'debug'); - $this->db->beginTrans(__METHOD__); - foreach($upgradeList as $fromVersion=>$toVersion) { + try { + $i=0; + $this->logsObj->log_by_class(__METHOD__ .": starting to run through the upgrade list, starting at (". $this->databaseVersion .")...", 'debug'); + $this->db->beginTrans(__METHOD__); + foreach($upgradeList as $fromVersion=>$toVersion) { + + $details = __METHOD__ .": upgrading from ". $fromVersion ." to ". $toVersion ."... "; + $this->logsObj->log_by_class($details, 'system'); + $this->do_single_upgrade($fromVersion); + $this->get_database_version(); + $i++; + + $details = __METHOD__ .": finished upgrade #". $i .", now at version (". $this->databaseVersion .")"; + $this->logsObj->log_by_class($details, 'system'); + } - $details = __METHOD__ .": upgrading from ". $fromVersion ." to ". $toVersion ."... "; - $this->logsObj->log_by_class($details, 'system'); - $this->do_single_upgrade($fromVersion); - $this->get_database_version(); - $i++; + if($this->databaseVersion == $this->versionFileVersion) { + $this->logsObj->log_by_class(__METHOD__ .": finished upgrading after performing (". $i .") upgrades", 'debug'); + $this->newVersion = $this->databaseVersion; + } + else { + $this->error_handler(__METHOD__ .": finished upgrade, but version wasn't updated (expecting '". $this->versionFileVersion ."', got '". $this->databaseVersion ."')!!!"); + } + $this->remove_lockfile(); - $details = __METHOD__ .": finished upgrade #". $i .", now at version (". $this->databaseVersion .")"; - $this->logsObj->log_by_class($details, 'system'); + $this->db->commitTrans(); } - - if($this->databaseVersion == $this->versionFileVersion) { - $this->logsObj->log_by_class(__METHOD__ .": finished upgrading after performing (". $i .") upgrades", 'debug'); - $this->newVersion = $this->databaseVersion; + catch(exception $e) { + $this->error_handler(__METHOD__ .": upgrade aborted:::". $e->getMessage()); + $this->db->rollbackTrans(); } - else { - $this->error_handler(__METHOD__ .": finished upgrade, but version wasn't updated (expecting '". $this->versionFileVersion ."', got '". $this->databaseVersion ."')!!!"); - } - $this->remove_lockfile(); - - $this->db->commitTrans(); } } }//end perform_upgrade() @@ -420,10 +432,6 @@ } } - if($retval !== false) { - $this->logsObj->log_by_class("Upgrading ". $retval ." versions, from (". $this->databaseVersion .") to (". $this->versionFileVersion .")", 'debug'); - } - return($retval); }//end check_for_version_conflict() //========================================================================= @@ -502,7 +510,7 @@ $this->error_handler(__METHOD__ .": target version not specified, unable to proceed with upgrade for ". $versionIndex); } } - $this->logsObj->log_by_class("Finished upgrade to ". $targetVersion); + $this->logsObj->log_by_class("Finished upgrade to ". $targetVersion, 'system'); }//end do_single_upgrade() //========================================================================= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |