diff --git a/include/class.osticket.php b/include/class.osticket.php index b877527f007638267cab97e5acf7ac4dca4b83f1..7d75834d414e13be63e155548d118b6d6b2a701e 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -242,8 +242,8 @@ class osTicket { } - function logDebug($title, $message, $alert=false) { - return $this->log(LOG_DEBUG, $title, $message, $alert); + function logDebug($title, $message, $force=false) { + return $this->log(LOG_DEBUG, $title, $message, false, $force); } function logInfo($title, $message, $alert=false) { @@ -266,7 +266,7 @@ class osTicket { 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. switch($priority) { @@ -292,7 +292,7 @@ class osTicket { $this->alertAdmin($title, $message); //Logging everything during upgrade. - if($this->getConfig()->getLogLevel()<$level && !$this->isUpgradePending()) + if($this->getConfig()->getLogLevel()<$level && !$force) return false; //Save log based on system log level settings. diff --git a/include/class.upgrader.php b/include/class.upgrader.php index 076a00ab5366af12ef81c63f520dc0e3c21a97e9..d0f20004086d0e09474681e13ddb57e79f112765 100644 --- a/include/class.upgrader.php +++ b/include/class.upgrader.php @@ -326,11 +326,10 @@ class StreamUpgrader extends SetupWizard { function doTask() { - global $ost; if(!($task = $this->getTask())) return false; //Nothing to do. - $ost->logDebug( + $this->log( sprintf('Upgrader - %s (task pending).', $this->getShash()), sprintf('The %s task reports there is work to do', get_class($task)) @@ -379,7 +378,7 @@ class StreamUpgrader extends SetupWizard { if(($info = $this->readPatchInfo($patch)) && $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->phash = $phash; @@ -405,10 +404,14 @@ class StreamUpgrader extends SetupWizard { return true; } - /************* TASKS **********************/ - function cleanup() { + function log($title, $message, $level=LOG_DEBUG) { 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'; if(!file_exists($file)) //No cleanup script. @@ -416,12 +419,12 @@ class StreamUpgrader extends SetupWizard { //We have a cleanup script ::XXX: Don't abort on error? 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}"); return 0; } - $ost->logDebug('Upgrader', sprintf("%s: Unable to process cleanup file", + $this->log('Upgrader', sprintf("%s: Unable to process cleanup file", $this->phash)); return 0; } diff --git a/include/upgrader/streams/core/15b30765-dd0022fb.task.php b/include/upgrader/streams/core/15b30765-dd0022fb.task.php index 6e2739218ad0e9499fafc14294df6fefd5c4b1e9..bb2df98bdf338eefc81cc0c29777ea5b95ade1ce 100644 --- a/include/upgrader/streams/core/15b30765-dd0022fb.task.php +++ b/include/upgrader/streams/core/15b30765-dd0022fb.task.php @@ -153,7 +153,9 @@ class AttachmentMigrater extends MigrationTask { if(!($res=db_query($sql))) 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)) return 0; //Nothing else to do!! @@ -217,7 +219,8 @@ class AttachmentMigrater extends MigrationTask { $this->errors++; $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 return false; }