Skip to content

Commit 39c59e0

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Suppress stream errors in mysqlnd
2 parents a3d0752 + 24a19cc commit 39c59e0

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

ext/mysqlnd/mysqlnd_vio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ MYSQLND_METHOD(mysqlnd_vio, post_connect_set_opt)(MYSQLND_VIO * const vio, const
263263
}
264264

265265
net_stream->chunk_size = vio->data->options.net_read_buffer_size;
266+
net_stream->flags |= PHP_STREAM_FLAG_SUPPRESS_ERRORS;
266267
}
267268

268269
DBG_VOID_RETURN;

ext/mysqlnd/mysqlnd_wireprotocol.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,6 @@ size_t php_mysqlnd_cmd_write(MYSQLND_CONN_DATA * conn, void * _packet)
971971
MYSQLND_VIO * vio = conn->vio;
972972
MYSQLND_STATS * stats = conn->stats;
973973
MYSQLND_CONNECTION_STATE * connection_state = &conn->state;
974-
const unsigned int error_reporting = EG(error_reporting);
975974
size_t sent = 0;
976975

977976
DBG_ENTER("php_mysqlnd_cmd_write");
@@ -981,10 +980,6 @@ size_t php_mysqlnd_cmd_write(MYSQLND_CONN_DATA * conn, void * _packet)
981980
*/
982981
pfc->data->m.reset(pfc, stats, error_info);
983982

984-
if (error_reporting) {
985-
EG(error_reporting) = 0;
986-
}
987-
988983
MYSQLND_INC_CONN_STATISTIC(stats, STAT_PACKETS_SENT_CMD);
989984

990985
#ifdef MYSQLND_DO_WIRE_CHECK_BEFORE_COMMAND
@@ -1017,10 +1012,6 @@ size_t php_mysqlnd_cmd_write(MYSQLND_CONN_DATA * conn, void * _packet)
10171012
}
10181013
}
10191014
end:
1020-
if (error_reporting) {
1021-
/* restore error reporting */
1022-
EG(error_reporting) = error_reporting;
1023-
}
10241015
if (!sent) {
10251016
SET_CONNECTION_STATE(connection_state, CONN_QUIT_SENT);
10261017
}

main/php_streams.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ struct _php_stream_wrapper {
181181

182182
#define PHP_STREAM_FLAG_NO_FCLOSE 0x80
183183

184+
/* Suppress generation of PHP warnings on stream read/write errors.
185+
* Currently for internal use only. */
186+
#define PHP_STREAM_FLAG_SUPPRESS_ERRORS 0x100
187+
184188
#define PHP_STREAM_FLAG_WAS_WRITTEN 0x80000000
185189

186190
struct _php_stream {

main/streams/plain_wrapper.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
358358
/* TODO: Should this be treated as a proper error or not? */
359359
return bytes_written;
360360
}
361-
php_error_docref(NULL, E_NOTICE, "Write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
361+
if (!(stream->flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS)) {
362+
php_error_docref(NULL, E_NOTICE, "Write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
363+
}
362364
}
363365
return bytes_written;
364366
} else {
@@ -426,7 +428,9 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
426428
} else if (errno == EINTR) {
427429
/* TODO: Should this be treated as a proper error or not? */
428430
} else {
429-
php_error_docref(NULL, E_NOTICE, "Read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
431+
if (!(stream->flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS)) {
432+
php_error_docref(NULL, E_NOTICE, "Read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
433+
}
430434

431435
/* TODO: Remove this special-case? */
432436
if (errno != EBADF) {

main/streams/xp_socket.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ static ssize_t php_sockop_write(php_stream *stream, const char *buf, size_t coun
104104
}
105105
}
106106

107-
estr = php_socket_strerror(err, NULL, 0);
108-
php_error_docref(NULL, E_NOTICE, "Send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
107+
if (!(stream->flags & PHP_STREAM_FLAG_SUPPRESS_ERRORS)) {
108+
estr = php_socket_strerror(err, NULL, 0);
109+
php_error_docref(NULL, E_NOTICE,
110+
"Send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
109111
(zend_long)count, err, estr);
110-
efree(estr);
112+
efree(estr);
113+
}
111114
}
112115

113116
if (didwrite > 0) {

0 commit comments

Comments
 (0)