Add some more debugging goodies to this. $lastCurlErrno and $lastHttpResponse are...
authorChad Horohoe <demon@users.mediawiki.org>
Tue, 30 Sep 2008 19:58:56 +0000 (19:58 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Tue, 30 Sep 2008 19:58:56 +0000 (19:58 +0000)
includes/HttpFunctions.php

index a31bd9e..b20e3fd 100644 (file)
@@ -12,6 +12,9 @@
  */
 class Http {
 
+       public static $lastCurlErrno = 0;
+       public static $lastHttpResponse = 0;
+
        /**
         * Simple wrapper for Http::request( 'GET' )
         * @see Http::request()
@@ -82,16 +85,16 @@ class Http {
                        ob_end_clean();
 
                        # Don't return the text of error messages, return false on error
-                       $retcode = curl_getinfo( $c, CURLINFO_HTTP_CODE );
-                       if ( $retcode != 200 ) {
-                               wfDebug( __METHOD__ . ": HTTP return code $retcode\n" );
+                       self::$lastHttpResponse = curl_getinfo( $c, CURLINFO_HTTP_CODE );
+                       if ( self::$lastHttpResponse != 200 ) {
+                               wfDebug( __METHOD__ . ": HTTP return code " . self::$lastHttpResponse . "\n" );
                                $text = false;
                        }
                        # Don't return truncated output
-                       $errno = curl_errno( $c );
-                       if ( $errno != CURLE_OK ) {
+                       self::$lastCurlErrno = curl_errno( $c );
+                       if ( self::$lastCurlErrno != CURLE_OK ) {
                                $errstr = curl_error( $c );
-                               wfDebug( __METHOD__ . ": CURL error code $errno: $errstr\n" );
+                               wfDebug( __METHOD__ . ": CURL error code " . self::$lastCurlErrno . ": $errstr\n" );
                                $text = false;
                        }
                        curl_close( $c );