From fbeb65ddccc4d809e82b27dedc3435af7f8e6702 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Fri, 6 Jul 2012 21:55:01 -0400 Subject: [PATCH] * Email upgrade errors to staff upgrading the system. * Append page url to error alerts - useful in determining which page triggered the error. --- include/class.osticket.php | 6 +++++- include/class.setup.php | 1 + include/class.upgrader.php | 23 ++++++++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/include/class.osticket.php b/include/class.osticket.php index fbbbb7dbf..66938cc7c 100644 --- a/include/class.osticket.php +++ b/include/class.osticket.php @@ -38,7 +38,7 @@ class osTicket { //DB based session storage was added starting with v1.7 // which does NOT have DB Version - if($this->config && !$this->getConfig()->getDBversion()) + if($this->config && !$this->getConfig()->getDBVersion()) $this->session = osTicketSession::start(SESSION_TTL); // start DB based session else session_start(); @@ -137,6 +137,10 @@ class osTicket { if(!($to=$this->getConfig()->getAdminEmail())) $to=ADMIN_EMAIL; + + //append URL to the message + $message.="\n\n".THISPAGE; + //Try getting the alert email. $email=null; if(!($email=$this->getConfig()->getAlertEmail())) diff --git a/include/class.setup.php b/include/class.setup.php index a49f87f13..e566f2bf0 100644 --- a/include/class.setup.php +++ b/include/class.setup.php @@ -58,6 +58,7 @@ Class SetupWizard { @mysql_query('SET SESSION SQL_MODE =""'); foreach($statements as $k=>$sql) { + //Note that we're not using db_query - because we want to control how errors are reported. if(mysql_query($sql)) continue; $error = "[$sql] ".mysql_error(); if($abort) diff --git a/include/class.upgrader.php b/include/class.upgrader.php index 73c647602..4487e53b2 100644 --- a/include/class.upgrader.php +++ b/include/class.upgrader.php @@ -49,16 +49,29 @@ class Upgrader extends SetupWizard { $this->migrater = new DatabaseMigrater($this->signature, SCHEMA_SIGNATURE, $this->sqldir); } - function getStops() { - return array('7be60a84' => 'migrateAttachments2DB'); - } - function onError($error) { - global $ost; + global $ost, $thisstaff; $ost->logError('Upgrader Error', $error); $this->setError($error); $this->setState('aborted'); + + //Alert staff upgrading the system - if the email is not same as admin's + // admin gets alerted on error log (above) + if(!$thisstaff || !strcasecmp($thisstaff->getEmail(), $ost->getConfig()->getAdminEmail())) + return; + + $email=null; + if(!($email=$ost->getConfig()->getAlertEmail())) + $email=$ost->getConfig()->getDefaultEmail(); //will take the default email. + + $subject = 'Upgrader Error'; + if($email) { + $email->send($thistaff->getEmail(), $subject, $error); + } else {//no luck - try the system mail. + Email::sendmail($thistaff->getEmail(), $subject, $error, sprintf('"osTicket Alerts"<%s>', $thistaff->getEmail())); + } + } function isUpgradable() { -- GitLab