From a9d458a2cc7e098928b430277000b7c1dfcbf36f Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 16 Sep 2011 20:08:33 +0000 Subject: [PATCH] Noticed in apache error logs (see below). If the length of the message is longer than the maximum length, only send what will fit Sep 16 20:07:28 10.0.2.193 apache2[28441]: PHP Warning: socket_sendto() [function.socket-sendto]: unable to write to socket [90]: Message too long in /home/wikipedia/common/php-1.17-test/includes/GlobalFunctions.php on line 464 Sep 16 20:07:29 10.0.2.193 apache2[26511]: PHP Warning: socket_sendto() [function.socket-sendto]: unable to write to socket [90]: Message too long in /home/wikipedia/common/php-1.17-test/includes/GlobalFunctions.php on line 464 --- includes/GlobalFunctions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 33cff2c59e..13fe67f0b7 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -867,7 +867,14 @@ function wfErrorLog( $text, $file ) { if ( !$sock ) { return; } - socket_sendto( $sock, $text, strlen( $text ), 0, $host, $port ); + + $len = strlen( $text ); + $maxLen = socket_get_option( $sock, SOL_UDP, SO_SNDBUF ); + + if ( $len > $maxLen ) { + $len = $maxLen - 1; + } + socket_sendto( $sock, $text, $len, 0, $host, $port ); socket_close( $sock ); } else { wfSuppressWarnings(); -- 2.20.1