svn: /web/php/trunk/ include/site.inc results.php

From: Date: Tue, 04 May 2010 18:08:14 +0000
Subject: svn: /web/php/trunk/ include/site.inc results.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-8117@lists.php.net to get a copy of this message
philip Tue, 04 May 2010 18:08:14 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=298985 Log: Added debugging info to fetch_contents(), and enabled track_errors until we require 5.2+ and/or do better error handling. Reveals too much info? Helps deal with bugs like #51679 Bug: http://bugs.php.net/51679 (Open) This mirror does not support search Changed paths: U web/php/trunk/include/site.inc U web/php/trunk/results.php Modified: web/php/trunk/include/site.inc =================================================================== --- web/php/trunk/include/site.inc 2010-05-04 17:50:47 UTC (rev 298984) +++ web/php/trunk/include/site.inc 2010-05-04 18:08:14 UTC (rev 298985) @@ -177,6 +177,8 @@ // Compatibility function to fetch data from external source function fetch_contents($url, $headers = false) { + $terrors_setting = ini_set('track_errors', true); + if(function_exists('file_get_contents') && ini_get('allow_url_fopen')) { $context = null; $opts = array('user_agent' => 'php.net'); @@ -198,7 +200,10 @@ } if (!$data) { - return array("ERROR" => "Unable to find a way to retrieve data with file_get_contents"); + return array( + 'ERROR_NOTE' => 'Unable to find a way to retrieve data with file_get_contents', + 'ERROR_LAST' => $php_errormsg, + ); } return $data; @@ -226,7 +231,10 @@ } } if (!$data) { - return array("ERROR" => "Unable to find a way to retrieve data with curl"); + return array( + 'ERROR_NOTE' => 'Unable to find a way to retrieve data with curl', + 'ERROR_LAST' => $php_errormsg, + ); } return $data; @@ -262,7 +270,10 @@ return $header; } if (!$data) { - return array("ERROR" => "Unable to find a way to retrieve data with fsockopen"); + return array( + 'ERROR_NOTE' => 'Unable to find a way to retrieve data with fsockopen', + 'ERROR_LAST' => $php_errormsg, + ); } return $data; @@ -270,7 +281,10 @@ // TODO: Log if we get here // Redirect to www.php.net ? - return array("ERROR" => "Unable to find a way to retrieve data"); + return array( + 'ERROR_NOTE' => 'Unable to find a way to retrieve data', + 'ERROR_LAST' => $php_errormsg, + ); } // Compatibility function to fetch headers from external source @@ -281,7 +295,7 @@ $headers = get_headers($url, 1); } else { $data = fetch_contents($url, true); - if (isset($data["ERROR"])) { + if (isset($data["ERROR_NOTE"])) { return null; } foreach($data as $line) { Modified: web/php/trunk/results.php =================================================================== --- web/php/trunk/results.php 2010-05-04 17:50:47 UTC (rev 298984) +++ web/php/trunk/results.php 2010-05-04 18:08:14 UTC (rev 298985) @@ -47,7 +47,8 @@ $data = fetch_contents($url); if (is_array($data)) { - $comment = '<!-- ' .$data["ERROR"]. '-->'; + // FIXME: if (is_authenticated()) ... + $comment = '<!-- ' .print_r($data, true). '-->'; exit_with_pretty_error("Search error", "Internal error", "This mirror does not support searches, please report this error to <a href='/contact'>our webmasters</a>" . $comment); } $res = unserialize($data);

« previous php.webmaster (#8117) next »