User tests: Successful: Unsuccessful:
Pull Request for Issue # .
Filter raw JSON response, catch any PHP warnings and add them to error messages of JSON response.
It fixes case when there is a PHP warning in response. Now there will be no message displayed to the user, because parsing JSON response would fail.
You will get similar response:
<br />
<b>Warning</b>: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages
:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in <b>/libraries/vendor/phpmailer/phpmailer/class.smtp.php</b> on line
<b>343</b><br />
{"success":true,"message":null,"messages":{"notice":["SMTP Error: Could not connect to SMTP host."],"error"
:["Test mail could not be sent."]},"data":false}
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
I agree that it could be resolved by PHP Mailer Team. But before that or if there will be any other php warning in the JSON response, user would not see any message and will be confused. He would think that send test email feature is not working and will be asking on forum, because we did not handle warnings
IMO an isolated fix like this for one JSON driven action is more a hack
than a fix. If you want to make sure all JSON based requests always give a
valid response in Joomla, you need to go deeper than fixing this single use
case.
On Wednesday, March 30, 2016, Piotr Moćko notifications@github.com wrote:
I agree that it could be resolved by PHP Mailer Team. But before that or
if there will be any other php warning in the JSON response, user would not
see any message and will be confused. He would think that send test email
feature is not working and will be asking on forum, because we did not
handle warnings—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#9676 (comment)
Not regarding this case in concrete. i can see the needing adding error messages in case there is no connection or any other problem in the ajax call.
ups mbabker already said that.
I will create some JS function in Joomla core.js to handle ajax response
filtering if you think that it would be enough.
I do not see any possibility to handle it globally in PHP before displaying
response.
This is also the case when it is needed, because after clicking Send test
email button there will be no reaction in user interface and no message
would be displayed like nothing had happened.
i think the json is rendered here
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/document/json.php#L66
In most cases it is genereted by JResponseJson
https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/response/json.php
And it would not be possible to strip out other output generated before
Category | ⇒ | JavaScript |
@piotrmocko if you apply this patch (#9685) you still have a problem with the php warning, right?
Yes, it would not help, as response output would not have a valid JSON and jQuery would fail.
I have been fighting with it for a long time in my Perfect Ajax Popup Contact Form.
The only possible way to handle PHP warnings in output or some other stuff thrown to the output by some bad coded system plugins is to filter JSON response before parsing it into object.
@nikosdion in his extensions is putting JSON response between hashes ###{"success:true,...}###
and after receiving it, it is being stripped out, and any warning which would occur before or after response would not break handling this response.
@piotrmocko i think you can now close this one in favor of #9685
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-01 07:52:07 |
Closed_By | ⇒ | piotrmocko |
the problem here, IMHO is the php warnings in phpmailer class.
In this case i think you're referring to https://github.com/joomla/joomla-cms/blob/staging/libraries/vendor/phpmailer/phpmailer/class.smtp.php#L334
which is the phpmailer SMTP class, so the warning if it's a problem it should be resolved by phpmailer team: https://github.com/PHPMailer/PHPMailer/issues