Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

class.dept.php - getAlertEmail() possible bug

Hi, it looks to me as if there is a bug in the getAlertEmail() function in class.dept.php.

around line 147 it has $cfg->getDefaultEmail(), which surely should be $cfg->getAlertEmail() ??

Otherwise its just functionallly equivilent to getEmail() and never sends to the default alert email.

Comments

  • What is your environment versions that you are using in which you found this on? 

    Webserver and version, SQL Version, PHP version etc...  

  • OS Ticket v1.10 (901e5ea)
    Centos 7
    Apache 2.4
    Mysql
    5.6.35
    php
    5.6.30

    I've chenged it on my system and alert mails work as I'd expect now, whereas previouly they never got sent to the alert address
  • You changed what exactly? I am a little lost because you state there is a bug, then you say you changed "it" on your system and it works as you expected, but previously it never sent to the alert address. Can you clarify a bit more?

  • The source code for class.dept.php ships with the function

        /**
         * getAlertEmail
         *
         * Fetches either the department email (for replies) if configured.
         * Otherwise, the system alert email address is used.
         */
        function getAlertEmail() {
            global $cfg;

            if ($this->email)
                return $this->email;

            return $cfg ? $cfg->getDefaultEmail() : null;
        }

    Its my belief that this SHOULD be 

        /**
         * getAlertEmail
         *
         * Fetches either the department email (for replies) if configured.
         * Otherwise, the system alert email address is used.
         */
        function getAlertEmail() {
            global $cfg;

            if ($this->email)
                return $this->email;

            return $cfg ? $cfg->getAlertEmail() : null;
        }

    Otherwise the default alert email set in the configuration option (admin->email->settings->default alert email) does not get used in the situation where no department alert email has been set. In this circumstance the default system email is used. Consequently on my system I have made this code change and alert emails now behave as I would expect, where as in the original default installation, alert emails with no department override were sent drom the default system email. In my view this is a bug.

    I'm not asking for any help and I don't have any problem about it, but it my research trying to find why my alert emails were not being sent correctly I discovered several earlier posts that were trying to understand the problem and not getting answers that solved the problem that I was experiencing.

    I've merely opened this thread so that other people who may be experiencing the same problem, will have a possible solution to try, and also to alert the developers that IF this IS a bug, they can fix it for a subsequent release.

    I'm no PHP expert, but making the change above has fixed the behaviour to be both as I would expect and as I previously experienced with my old v1.6 installation that I have just upgraded.
  • If you think it is a bug, and that this is the solution for it, I suggest you report it/do a pull request at github along with your solution if you want the devs to see it and take a look at it.


  • I've reported this thread to the devs to take a look at also.
Sign In or Register to comment.