Support

Akeeba Ticket System

#16588 ats-mail-fetch.php gives errors on J! 2.5.11, PHP 5.3.21

Posted in ‘Akeeba Ticket System for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Akeeba Ticket System version
n/a

Latest post by s.manzi on Wednesday, 03 July 2013 02:22 CDT

s.manzi
 Hi Nicholas,

I'm trying to set up the cron job to fetch mail for ATS, but I'm getting the following errors from ats-mail-fetch.php:

[28-Jun-2013 18:10:03 US/Central] PHP Warning:  fwrite() expects parameter 1 to be resource, string given in /home/pgdev/public_html/libraries/joomla/application/cli.php on line 252
[28-Jun-2013 18:10:03 US/Central] PHP Warning:  fwrite() expects parameter 1 to be resource, string given in /home/pgdev/public_html/libraries/joomla/application/cli.php on line 252
[28-Jun-2013 18:10:03 US/Central] PHP Warning:  fwrite() expects parameter 1 to be resource, string given in /home/pgdev/public_html/libraries/joomla/application/cli.php on line 252
[28-Jun-2013 18:10:03 US/Central] PHP Warning:  fwrite() expects parameter 1 to be resource, string given in /home/pgdev/public_html/libraries/joomla/application/cli.php on line 252
[28-Jun-2013 18:10:03 US/Central] PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /home/pgdev/public_html/libraries/joomla/application/cli.php:252) in /home/pgdev/public_html/libraries/joomla/session/session.php on line 532
[28-Jun-2013 18:10:03 US/Central] PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/pgdev/public_html/libraries/joomla/application/cli.php:252) in /home/pgdev/public_html/libraries/joomla/session/session.php on line 532
[28-Jun-2013 18:10:03 US/Central] PHP Fatal error:  Class 'JComponentHelper' not found in /home/pgdev/public_html/libraries/joomla/access/access.php on line 306


J! is 2.5.11 and PHP is 5.3.21
any idea?

Also, is it normal that I had to set permissions to 744 for ats-mail-fetch.php in order to run it?

One more, unrelated thing: can you please notify me too when the "private tickets only" feature will be available? For the time being I managed to "fake" the feature by setting private by default and then hiding some controls via CSS display:none, but I'd really like to see it natively implemented...

Have a nice day!

Sergio

nicholas
Akeeba Staff
Manager
The first few warnings come from Joomla! core code, namely JApplicationCli. I have seen that before. It means that you are accidentally using the PHP CGI (Common Gateway Interface - used to serve web pages) binary instead of the PHP CLI (Command Line Interface - used to run command-line scripts) binary. The fatal error you get is also linked to the above. Please ask your host to give you the path to the PHP 5.3 (or 5.4) CLI binary and use that in your CRON job.

> Also, is it normal that I had to set permissions to 744 for ats-mail-fetch.php in order to run it?

No. Normally you only need 0644 permissions. This may also be related to you using the PHP CGI binary instead of the PHP CLI binary.

> One more, unrelated thing: can you please notify me too when the "private tickets only" feature will be available?

It's already there in version 1.2.0 :) Go to the ATS Category editor page and you'll see a new option called "Allow only". Set it to "Private". Done!

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

s.manzi
Thanks, Nic!

I've just opened a ticket with my provider (site5.com) asking for the path to the PHP CLI.
I keep this ticket open just in case and I will close it as soon as everything will be OK.

Wooops... I missed the new option "Allow only" option in ATS 1.2.0.... :-/ but.... couldn't you have released it just "a day before"??? :-) :-)

Thanks again and have a nice day.

Sergio

s.manzi
Hi Nic,

/usr/bin/php-cli *almost* did the trick, but I'm still getting a Joomla! core error:
Akeeba Ticket System -- Fetch email for the Reply By Email feature
Copyright 2011-2013 Nicholas K. Dionysopoulos / AkeebaBackup.com
===============================================================================
Preparing to check for email

Fatal error: Class 'JComponentHelper' not found in /home/pgdev/public_html/libraries/joomla/access/access.php on line 306

libraries/joomla/access/access.php has this around line 306:
if (empty($userId))
{
   $query->from('#__usergroups AS a');
   $query->where('a.id = ' . (int) JComponentHelper::getParams('com_users')->get('guest_usergroup', 1));
}

time to... "kill a kitten"? ;-)

Cheers!

Sergio

nicholas
Akeeba Staff
Manager
Um... can you please try installing the latest dev release? It seems that the ticket creation by email was FUBAR.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

s.manzi
Nic,

things are getting better, but there are still some issues.
First let me tell you that before installing the latest dev release, ceb5369(Alpha), I tried to to turn off email ticket creation with the latest stable release, 1.2.0, but the fatal error in access.php didn't go away. So, I think there is something wrong beside the email ticket creation feature.

I then installed ceb5369. First small problem with it is that ATS, even if I'm on "Alpha release channel" for upgrades, says that there is an upgrade available and proposes my to upgrade to 1.2.0 (which of course I didn't...).

With ceb5369 mail is fetched (I'm using IMAP to get it...), but there is still a small "glitch": sometimes (not always) I get two warnings:
Preparing to check for email

Warning: Invalid argument supplied for foreach() in /home/pgdev/public_html/libraries/joomla/string/string.php on line 970
Email was successfully fetched

Warning: mysqli_ping(): Couldn't fetch mysqli in /home/pgdev/public_html/libraries/joomla/database/database/mysqli.php on line 190

It seems to me that this warnings are issued *when there is new mail to fetch* and, BTW, I'm using mysqli interface.

So, although with small glitches, it seems mail fetching is working now with the dev release!

I have two more issues with ATS, about the sender identity and how tickets are identified when received by email: basically I would like to have the sender identity configurable and not forced to be the Joomla! installation mail address and I would like tickets to be identified by the subject instead of the line in the mail body. If you wish I can open a new ticket about those two...

Thanks for your help, Nic. Apreciated!

Sergio

nicholas
Akeeba Staff
Manager
These warnings come from the Joomla! core and can be ignored.

> I have two more issues with ATS, about the sender identity and how tickets are identified when received by email: basically I would like to have the sender identity configurable and not forced to be the Joomla! installation mail address and I would like tickets to be identified by the subject instead of the line in the mail body. If you wish I can open a new ticket about those two...

Neither is possible.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

s.manzi
Hi Nicholas,

thank-you for your answer.

So... nothing to worry about those Joomla! core warnings, good!

About the "neither is possible", well... I've already seen you doing "impossible things"!! : -)
Do you remember my impossible request for Akeeba Subscriptions about "removing users from a group when upgrading"? It was impossible, but then "Level relations" came and it became possible!! :-) (BTW, I've never said thank you for that: I feel guilty...)

Forgive me if I insist: I just want you to explain you why I think it can be a good idea in some scenarios (which of course is not the yours at akeebabackup.com):

If you allow ticket creations by e-mail and a user makes a mistake answering to an open ticket erasing the magical line... puff! A new ticket is created, and not having the possibility to merge tickets this can become quite a mess.

Another problem is that some mail UA (e.g. Thunderbird) by default *appends* replies to the original text, so if the user makes a mistake you can easily get an empty reply...

I understand why you did the way you did: to not have replies littered by the original text. But also keep in mind that some UA (Microsoft Outlook) prepend the whole email header to the text when answering, so you have the reply littered by the header anyway. Thunderbird is nicer but it too litters the reply with a: "on [this date] [this user] wrote", and that too comes into the answer.

So, IMHO, it would be quite a good idea to have *also* the possibility to dispatch tickets answers received by email via the subject field. At the end of the day this how most ticketing systems work...

I would not insist further but, as I said, I've already seen you doing the impossible, so I can still keep a hope...

Best regards and have a nice day!

Sergio

nicholas
Akeeba Staff
Manager
OK, let me give more info.

> I would like to have the sender identity configurable

Nope. This is something I am not going to implement because it would require that most users also provide different connection information to their mail server. I'd have to add 13 new fields per subscription category. It's not impossible to do, it's just insanely complicated for everyone: me, you, other users...

> I would like tickets to be identified by the subject instead of the line in the mail body

Worst idea ever. This is how this feature started up with. Then I noticed that mail clients may add "re" "RE" "Re" "Antwort" "AW" "Απ" "Απάντηση" or any other localised "reply" prefix OR SUFFIX (for crying out loud!!!) in the message subject. And then again I have noticed many people changing the subject of the email so much that it ain't fun to try to parse that. So, between resorting to different email addresses per category and me ending up in the asylum, guess which alternative I chose. So, no, I'm not going to get crazy trying to solve an unsolvable problem :)

> If you allow ticket creations by e-mail and a user makes a mistake answering to an open ticket erasing the magical line... puff! A new ticket is created, and not having the possibility to merge tickets this can become quite a mess.

Actually, there is an invisible email header that is preserved by most email clients. If this header is present the message will become a reply, not a new ticket. I've tried very hard to fix stupid :)

> Another problem is that some mail UA (e.g. Thunderbird) by default *appends* replies to the original text, so if the user makes a mistake you can easily get an empty reply...

And the email reads: Reply above this line. If the user is so dumb that they can't understand what that means you're better off not reading their reply to the ticket.

> I understand why you did the way you did: to not have replies littered by the original text. But also keep in mind that some UA (Microsoft Outlook) prepend the whole email header to the text when answering, so you have the reply littered by the header anyway. Thunderbird is nicer but it too litters the reply with a: "on [this date] [this user] wrote", and that too comes into the answer.

Again, that's why it reads reply ABOVE and not BELOW this line.

> So, IMHO, it would be quite a good idea to have *also* the possibility to dispatch tickets answers received by email via the subject field. At the end of the day this how most ticketing systems work...

Wrong assumption. If this is how a ticketing system works its developer is either in the asylum or going there very fast. Most commercial ticket systems –e.g. GitHub– work based on a customised email address per ticket. Unfortunately this is not an option for a Joomla! component. The other trick commonly used is the thread ID in the mail server which again is not an option. This leaves us with a hidden email header (check!) and a reply above line (check!). In fact, I didn't invent this method. Many services use it, like Assembla's ticket system.

> I would not insist further but, as I said, I've already seen you doing the impossible, so I can still keep a hope...

I know how to pick my battles with impossible tasks :) I only deal with those that have a fair chance of conquering. When a battle is already fought and lost I am not willing to fight it again. And, you bet, I have already thought of what you said, I've already tried it, it didn't work and I came to the existing solution.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

s.manzi
Hi Nic,

As I said I will not insist any further with my requests. The first (even it can be useful in some situation), I understand it is quite complicate to implement: basically it will mean to move all email parameters from the component options level to the categories level and it also will make the mail fetcher more complicated (looping for each category). The second... I know you're a... "deep thinker" and I trust your opinion.

There are two more problems, anyway, and sorry if hijack this ticket with them:

1) as I already said ATS continue to propose me 1.2.0 as an upgrade even if yesterday a new alpha has been released (yes, I configured ATS on the "alpha" channel upgrade path). Not a problem at all for me, but I think you would know about this.

2) I've been notified by my provider that they had to reboot my VPS due to excessive memory usage and they pinpointed the issue with ats-mail-fetch.php. :-/
It is true that yesterday afternoon I shortened the cron period to two minutes (yes I know it is not reasonable: it was only for quicken-up my tests) and forgot to set it back to a more reasonable value. But... is it possible that there is a memory leak in ats-mail-fetch.php? Can I help you somehow debugging it? For the time being I just turned the cron job off. Let me know if there is something I can do.

I'm now going to install com_ats-git_91c3135, but from a quick look I gave to the diffs, it doesn't seems to have anything changed regarding ats-mail-fetch.

Have a good day!

Sergio

nicholas
Akeeba Staff
Manager
You know why I wrote the don't run this more frequently than 5 minutes instruction in the docs? It's because this will happen :) What is most likely going on is that the second CRON job would start when the first one was still running. This causes huge CPU and memory usage.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

s.manzi
thanks, Nic...

Sergio walks away in the sunset, his tail between legs... :-( ;-(

take care!

nicholas
Akeeba Staff
Manager
Best ticket reply EVER!

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

s.manzi
:-) tnx!

I think you can close it now...

s.manzi
ehi, wait... I know what happened tonight to my system!! Yes of course the 2 minutes cron was a mistake, but there is more, and, yes, even that is mostly due by "bad administration" from me, but you are probably interested anyway:

Yesterday night I "demoed" the site I'm building to a partner and I've subscribed to the site as a new user with a fake e-mail address (1st error) [email protected]

Then I opened a ticket through the web interface.
ATS tried to deliver a copy of the ticket to the fake address, [email protected]
Surely enough my "Mailer-Daemon" returned the undeliverable mail to my inbox (the inbox of the user defined in Joomla! configuration that of course is the same used by ATS).
Now, ats-mail-fetch.php fetched this email, interpreted it as a new ticket creation by email but of course replied to Mailer-Daemon stating that he was not known as a user and he cannot open a ticket by email
Now (2nd administration error) Mailer-Daemon does not have an inbox so it bounced the mail back to my site inbox.

Looooooop!! :-)

nicholas
Akeeba Staff
Manager
Damn, that's the exact reason why I don't like creating tickets by email :( You can disable the email for new and invalid tickets, but this may screw up legitimate users trying to send a ticket from the wrong email address. It's also impossible to detect mailer daemon messages because every one uses a slightly different format. Having to use a special keyword in the subject or body was another thing that crossed my mind, but it all starts becoming very complicated very fast :(

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

s.manzi
"yeap... I know that feeling..." (50 bonus points if you get the movie citation right!) :-)

Nic, I completely agree with you and I will turn off email ticket creation and call it a day (actually I don't NEED that).

There must be a way out of it, anyway...

Cheers!

Sergio












nicholas
Akeeba Staff
Manager
I guess the movie reference is "Paris, Texas".

Anyway, I guess there should be some solution, I just don't have it (yet?)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

s.manzi
I owe you 50 bonus points (and a beer as an extra)!

maybe an "X-Automatically-generated-by-ATS" email header?
Then the fetcher could scan the returned email (actually any email) for this header and discard the email if found?

Edit: I mean, in case of a returned email the original header would be in the returned email body, so you can easily find it...

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!