Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Protocol\AbstractProtocol: verbose errors #116

Merged
merged 2 commits into from
Feb 14, 2017

Conversation

Slamdunk
Copy link
Contributor

@Slamdunk Slamdunk commented Oct 11, 2016

Recently an update of openssl stopped our app (aright) becase one of our partner had messy servers:

$ php -r 'var_dump(stream_socket_client("ssl://hide.me:465", $errorNum, $errorStr));var_dump($errorNum, $errorStr);'

Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure in Command line code on line 1

Warning: stream_socket_client(): Failed to enable crypto in Command line code on line 1

Warning: stream_socket_client(): unable to connect to ssl://hide.me:465 (Unknown error) in Command line code on line 1
bool(false)
int(0)
string(0) ""

But it took us a while to get the right error, because an anonym Could not open socket was the only message thrown by the smtp protocol.
Also, many times $errorNum and $errorStr are empty.

With this PR the error-suppressing operator @ is deleted and a specific error handler to exception function handles the possible warnings.

@weierophinney weierophinney self-assigned this Feb 14, 2017
@weierophinney weierophinney added this to the 2.7.3 milestone Feb 14, 2017
@weierophinney weierophinney merged commit 140ada9 into zendframework:master Feb 14, 2017
weierophinney added a commit that referenced this pull request Feb 14, 2017
Protocol\AbstractProtocol: verbose errors
weierophinney added a commit that referenced this pull request Feb 14, 2017
weierophinney added a commit that referenced this pull request Feb 14, 2017
weierophinney added a commit that referenced this pull request Feb 14, 2017
@weierophinney
Copy link
Member

Thanks, @Slamdunk

@Slamdunk Slamdunk deleted the verbose-errors branch February 14, 2017 17:49
$this->socket = @stream_socket_client($remote, $errorNum, $errorStr, self::TIMEOUT_CONNECTION);
set_error_handler(
function ($error, $message = '') {
throw new Exception\RuntimeException(sprintf('Could not open socket: %s', $message), $error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't such code faulty that error handler is not restored when exception is thrown?

point being that throwing exception not necessarily terminate the program, it may resume working with this error handler being still set.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants