Skip to content
Snippets Groups Projects
Commit f300a765 authored by Jared Hancock's avatar Jared Hancock
Browse files

Always log stuff during upgrades (for real)

Anything that would happen after the last patch was applied would never be
logged, because the system would immediately indicate that no upgrade was
pending.
parent c104111c
No related branches found
No related tags found
No related merge requests found
...@@ -242,8 +242,8 @@ class osTicket { ...@@ -242,8 +242,8 @@ class osTicket {
} }
function logDebug($title, $message, $alert=false) { function logDebug($title, $message, $force=false) {
return $this->log(LOG_DEBUG, $title, $message, $alert); return $this->log(LOG_DEBUG, $title, $message, false, $force);
} }
function logInfo($title, $message, $alert=false) { function logInfo($title, $message, $alert=false) {
...@@ -266,7 +266,7 @@ class osTicket { ...@@ -266,7 +266,7 @@ class osTicket {
return $this->log(LOG_ERR, $title, $error, $alert); return $this->log(LOG_ERR, $title, $error, $alert);
} }
function log($priority, $title, $message, $alert=false) { function log($priority, $title, $message, $alert=false, $force=false) {
//We are providing only 3 levels of logs. Windows style. //We are providing only 3 levels of logs. Windows style.
switch($priority) { switch($priority) {
...@@ -292,7 +292,7 @@ class osTicket { ...@@ -292,7 +292,7 @@ class osTicket {
$this->alertAdmin($title, $message); $this->alertAdmin($title, $message);
//Logging everything during upgrade. //Logging everything during upgrade.
if($this->getConfig()->getLogLevel()<$level && !$this->isUpgradePending()) if($this->getConfig()->getLogLevel()<$level && !$force)
return false; return false;
//Save log based on system log level settings. //Save log based on system log level settings.
......
...@@ -326,11 +326,10 @@ class StreamUpgrader extends SetupWizard { ...@@ -326,11 +326,10 @@ class StreamUpgrader extends SetupWizard {
function doTask() { function doTask() {
global $ost;
if(!($task = $this->getTask())) if(!($task = $this->getTask()))
return false; //Nothing to do. return false; //Nothing to do.
$ost->logDebug( $this->log(
sprintf('Upgrader - %s (task pending).', $this->getShash()), sprintf('Upgrader - %s (task pending).', $this->getShash()),
sprintf('The %s task reports there is work to do', sprintf('The %s task reports there is work to do',
get_class($task)) get_class($task))
...@@ -379,7 +378,7 @@ class StreamUpgrader extends SetupWizard { ...@@ -379,7 +378,7 @@ class StreamUpgrader extends SetupWizard {
if(($info = $this->readPatchInfo($patch)) && $info['version']) if(($info = $this->readPatchInfo($patch)) && $info['version'])
$logMsg.= ' ('.$info['version'].') '; $logMsg.= ' ('.$info['version'].') ';
$ost->logDebug("Upgrader - $shash applied", $logMsg); $this->log("Upgrader - $shash applied", $logMsg);
$this->signature = $shash; //Update signature to the *new* HEAD $this->signature = $shash; //Update signature to the *new* HEAD
$this->phash = $phash; $this->phash = $phash;
...@@ -405,10 +404,14 @@ class StreamUpgrader extends SetupWizard { ...@@ -405,10 +404,14 @@ class StreamUpgrader extends SetupWizard {
return true; return true;
} }
/************* TASKS **********************/ function log($title, $message, $level=LOG_DEBUG) {
function cleanup() {
global $ost; global $ost;
// Never alert the admin, and force the write to the database
$ost->log($level, $title, $message, false, true);
}
/************* TASKS **********************/
function cleanup() {
$file = $this->getSQLDir().$this->phash.'.cleanup.sql'; $file = $this->getSQLDir().$this->phash.'.cleanup.sql';
if(!file_exists($file)) //No cleanup script. if(!file_exists($file)) //No cleanup script.
...@@ -416,12 +419,12 @@ class StreamUpgrader extends SetupWizard { ...@@ -416,12 +419,12 @@ class StreamUpgrader extends SetupWizard {
//We have a cleanup script ::XXX: Don't abort on error? //We have a cleanup script ::XXX: Don't abort on error?
if($this->load_sql_file($file, $this->getTablePrefix(), false, true)) { if($this->load_sql_file($file, $this->getTablePrefix(), false, true)) {
$ost->logDebug("Upgrader - {$this->phash} cleanup", $this->log("Upgrader - {$this->phash} cleanup",
"Applied cleanup script {$file}"); "Applied cleanup script {$file}");
return 0; return 0;
} }
$ost->logDebug('Upgrader', sprintf("%s: Unable to process cleanup file", $this->log('Upgrader', sprintf("%s: Unable to process cleanup file",
$this->phash)); $this->phash));
return 0; return 0;
} }
......
...@@ -153,7 +153,9 @@ class AttachmentMigrater extends MigrationTask { ...@@ -153,7 +153,9 @@ class AttachmentMigrater extends MigrationTask {
if(!($res=db_query($sql))) if(!($res=db_query($sql)))
return $this->error('Unable to query DB for attached files to migrate!'); return $this->error('Unable to query DB for attached files to migrate!');
$ost->logDebug("Attachment migration", 'Found '.db_num_rows($res).' attachments to migrate'); // Force the log message to the database
$ost->logDebug("Attachment migration", 'Found '.db_num_rows($res)
.' attachments to migrate', true);
if(!db_num_rows($res)) if(!db_num_rows($res))
return 0; //Nothing else to do!! return 0; //Nothing else to do!!
...@@ -217,7 +219,8 @@ class AttachmentMigrater extends MigrationTask { ...@@ -217,7 +219,8 @@ class AttachmentMigrater extends MigrationTask {
$this->errors++; $this->errors++;
$this->errorList[] = $what; $this->errorList[] = $what;
$ost->logDebug('Upgrader: Attachment Migrater', $what); // Log the error but don't send the alert email
$ost->logError('Upgrader: Attachment Migrater', $what, false);
# Assist in returning FALSE for inline returns with this method # Assist in returning FALSE for inline returns with this method
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment