Fixed corruption of long UDP debug log messages by using socket_sendto() instead...
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 18 Nov 2009 06:21:27 +0000 (06:21 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 18 Nov 2009 06:21:27 +0000 (06:21 +0000)
RELEASE-NOTES
includes/GlobalFunctions.php

index 38acde8..7ef10db 100644 (file)
@@ -638,6 +638,8 @@ Hopefully we will remove this configuration var soon)
 * (bug 21455) Fixed "Watch this page" checkbox appearing on some special pages
   even to non-logged in users
 * (bug 21551) Make Squid reponse limit configurable
+* Fixed corruption of long UDP debug log messages by using socket_sendto() 
+  instead of fsockopen() with fwrite().
 
 == API changes in 1.16 ==
 
index 85bbabb..1b6dc2a 100644 (file)
@@ -411,13 +411,18 @@ function wfErrorLog( $text, $file ) {
                        // IPv6 bracketed host
                        $protocol = $m[1];
                        $host = $m[2];
-                       $port = $m[3];
+                       $port = intval( $m[3] );
                        $prefix = isset( $m[4] ) ? $m[4] : false;
+                       $domain = AF_INET6;
                } elseif ( preg_match( '!^(tcp|udp):(?://)?([a-zA-Z0-9.-]+):(\d+)(?:/(.*))?$!', $file, $m ) ) {
                        $protocol = $m[1];
                        $host = $m[2];
-                       $port = $m[3];
+                       if ( !IP::isIPv4( $host ) ) {
+                               $host = gethostbyname( $host );
+                       }
+                       $port = intval( $m[3] );
                        $prefix = isset( $m[4] ) ? $m[4] : false;
+                       $domain = AF_INET;
                } else {
                        throw new MWException( __METHOD__.": Invalid UDP specification" );
                }
@@ -429,12 +434,12 @@ function wfErrorLog( $text, $file ) {
                        }
                }
 
-               $sock = fsockopen( "$protocol://$host", $port );
+               $sock = socket_create( $domain, SOCK_DGRAM, SOL_UDP );
                if ( !$sock ) {
                        return;
                }
-               fwrite( $sock, $text );
-               fclose( $sock );
+               socket_sendto( $sock, $text, strlen( $text ), 0, $host, $port );
+               socket_close( $sock );
        } else {
                wfSuppressWarnings();
                $exists = file_exists( $file );