[Cs-webdbupgrade-commits] SF.net SVN: cs-webdbupgrade:[37] trunk/0.1/cs_webdbupgrade.class.php
Status: Inactive
Brought to you by:
crazedsanity
|
From: <cra...@us...> - 2009-08-13 03:19:40
|
Revision: 37
http://cs-webdbupgrade.svn.sourceforge.net/cs-webdbupgrade/?rev=37&view=rev
Author: crazedsanity
Date: 2009-08-13 03:19:31 +0000 (Thu, 13 Aug 2009)
Log Message:
-----------
INTERMEDIATE: fixes for logging + some debugging.
/cs_webdbupgrade.class.php:
* __construct():
-- better checking on the value of $lockFile
-- drop some debugging
-- connect logger manually instead of calling connect_logger()
* check_internal_upgrades():
-- remove lots of debugging
* perform_upgrade():
-- suspend logging for the entire method & handle the pending logs at
the very end.
-- added some debugging
-- NOTE::: logging should only be suspended if $this->projectName
matches "cs-webdblogger".
* error_handler():
-- emit debugging messages
* do_log():
-- emit debugging messages
* connect_logger() [DELETED]:
-- stop allowing methods to call this... allowing this can lead to
situations where it overruns the database server with connections.
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-08-11 18:51:07 UTC (rev 36)
+++ trunk/0.1/cs_webdbupgrade.class.php 2009-08-13 03:19:31 UTC (rev 37)
@@ -130,7 +130,7 @@
else {
$this->config['RWDIR'] = constant(__CLASS__ .'-RWDIR');
}
- if(!is_string($lockFile)) {
+ if(is_null($lockFile) || !strlen($lockFile)) {
$lockFile = 'upgrade.lock';
}
$this->lockfile = $this->config['RWDIR'] .'/'. $lockFile;
@@ -148,19 +148,17 @@
throw new exception(__METHOD__ .": upgrade in progress: ". $this->fsObj->read($this->lockfile));
}
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
-
$this->check_internal_upgrades();
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
- try {
- $this->connect_logger();
+ try {
+ $loggerDb = new cs_phpDB(constant('DBTYPE'));
+ $loggerDb->connect($this->config['DBPARAMS'], true);
+ $this->logsObj = new cs_webdblogger($loggerDb, "Upgrade ". $this->projectName, false);
}
catch(exception $e) {
throw new exception(__METHOD__ .": failed to create logger::: ". $e->getMessage());
}
- $this->gfObj->debug_print($this,1);
$this->check_versions(false);
}//end __construct()
//=========================================================================
@@ -172,22 +170,18 @@
* Determine if there are any upgrades that need to be performed...
*/
private function check_internal_upgrades() {
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
$oldVersionFileLocation = $this->versionFileLocation;
$oldUpgradeConfigFile = $this->config['UPGRADE_CONFIG_FILE'];
$this->config['UPGRADE_CONFIG_FILE'] = dirname(__FILE__) .'/upgrades/upgrade.xml';
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
//set a status flag so we can store log messages (for now).
$this->internalUpgradeInProgress = true;
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
//do stuff here...
$this->set_version_file_location(dirname(__FILE__) .'/VERSION');
$this->read_version_file();
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
//if there is an error, then... uh... yeah.
try {
@@ -201,22 +195,16 @@
}
//do upgrades here...
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
$this->check_versions(true);
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
$this->internalUpgradeInProgress = false;
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
//reset internal vars.
$this->set_version_file_location($oldVersionFileLocation);
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
$this->config['UPGRADE_CONFIG_FILE'] = $oldUpgradeConfigFile;
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
$this->read_version_file();
-$this->gfObj->debug_print(__METHOD__ .": line#". __LINE__ ." (". $this->projectName ." - ". $this->versionFileLocation .") -- CONFIG::: ". $this->gfObj->debug_print($this->config,0),1);
}//end check_internal_upgrades()
//=========================================================================
@@ -341,6 +329,7 @@
//=========================================================================
private function perform_upgrade() {
+ $this->logsObj->suspendLogging=true;
//make sure there's not already a lockfile.
if($this->upgrade_in_progress()) {
//ew. Can't upgrade.
@@ -409,12 +398,17 @@
$this->db->commitTrans();
}
catch(exception $e) {
- $this->error_handler(__METHOD__ .": upgrade aborted:::". $e->getMessage());
+ $transactionStatus = $this->db->get_transaction_status(false);
+ $this->error_handler(__METHOD__ .": transaction status=(". $transactionStatus ."), upgrade aborted:::". $e->getMessage());
$this->db->rollbackTrans();
}
+ $this->logsObj->suspendLogging=false;
$this->do_log("Upgrade process complete", 'end');
}
}
+ $this->logsObj->suspendLogging=false;
+ $logsHandled = $this->logsObj->handle_suspended_logs();
+ $this->gfObj->debug_print(__METHOD__ .": done, handled (". $logsHandled .") logs that had been suspended... ",1);
}//end perform_upgrade()
//=========================================================================
@@ -1037,14 +1031,8 @@
//=========================================================================
public function error_handler($details) {
//log the error.
- $this->gfObj->debug_print($this->debugLogs,1);
if(!is_object($this->logsObj)) {
- if($this->internalUpgradeInProgress === true) {
- throw new exception(__METHOD__ .": error while running an internal upgrade::: ". $details);
- }
- else {
- $this->connect_logger();
- }
+ throw new exception(__METHOD__ .": error while running an internal upgrade::: ". $details);
}
if($this->internalUpgradeInProgress === false) {
$this->do_log($details, 'exception in code');
@@ -1091,24 +1079,8 @@
//=========================================================================
- private function connect_logger($logCategory=null) {
-
- cs_debug_backtrace(1);
-
- if(is_null($logCategory) || !strlen($logCategory)) {
- $logCategory = "Upgrade ". $this->projectName;
- }
-
- $loggerDb = new cs_phpDB(constant('DBTYPE'));
- $loggerDb->connect($this->config['DBPARAMS'], true);
- $this->logsObj = new cs_webdblogger($loggerDb, $logCategory, false);
- }//end connect_logger()
- //=========================================================================
-
-
-
- //=========================================================================
protected function do_log($message, $type) {
+ $this->gfObj->debug_print(__METHOD__ .": loggerSuspend=(". $this->logsObj->suspendLogging ."), type=(". $type ."), MESSAGE::: ". $message,1);
$this->debugLogs[] = array('project'=>$this->projectName,'upgradeFile'=>$this->config['UPGRADE_CONFIG_FILE'],'message'=>$message,'type'=>$type);
if($this->internalUpgradeInProgress === true) {
$this->storedLogs[] = func_get_args();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|