Syntax Error in email_functions.inc.php?

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
mkoch227
Posts: 666
Joined: Wed Jul 04, 2012 3:37 pm

Syntax Error in email_functions.inc.php?

Post by mkoch227 »

I was doing some work in email_functions.inc.php, and I noticed a something strange around lines 171-179 (this is HESK 2.6.0 beta 1's version of the file; however I noticed this error in the 2.5.5 version):

Code: Select all

/* Send email messages in previous languages (if required) */
if ($current_language != 'NONE')
{
    /* Send e-mail to staff */
    hesk_mail(implode(',',$recipients), $subject, $message );

    /* Reset list of email addresses */
    $recipients = array();
}
At "hesk_mail(implode...)", both $subject and $message haven't been declared/instantiated at this point. Is this just an oversight that will never occur, or is this just a "hidden" bug that hasn't been discovered yet?
Mike, Lead Developer of Image HESK: A surprisingly simple, user-friendly and FREE help desk software with integrated knowledgebase.
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Syntax Error in email_functions.inc.php?

Post by Klemen »

Hi Mike,

This block of code is only called when the $current_language variable (few lines further down the code) changed previously in a loop, so actually the $subject and $message generated in a previous loop (for a previously declared staff language setting) are used here.

This is used when staff members have different default languages set and HESK notifies each staff in his/her default language instead of the language the customer uses.

A new language is required, so
1. subject is generated
2. message is generated
3. $current_language changes
4. HESK loops until $current_language changes again and in the meantime buffers recipient email addresses
5. when language changes (or loop ends) the mail is sent

The final result is:
- send all emails in language 1
- send all emails is language 2
- send all emails in language 3
...
- language is reset to the default language

If I missed something else please let me know what you EXPECT to happen and what actually happens?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
mkoch227
Posts: 666
Joined: Wed Jul 04, 2012 3:37 pm

Re: Syntax Error in email_functions.inc.php?

Post by mkoch227 »

Ooh ok I see it now; at first it was a little bit confusing since there wasn't $subject or $message yet until after the first loop iteration, but it makes sense now. Thanks!
Mike, Lead Developer of Image HESK: A surprisingly simple, user-friendly and FREE help desk software with integrated knowledgebase.
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Syntax Error in email_functions.inc.php?

Post by Klemen »

Thanks for keeping an eye on it anyway :wink:
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply