]> granicus.if.org Git - php/commitdiff
Fixed bug #60523 (PHP Errors are not reported in browsers using built-in SAPI)
authorXinchen Hui <laruence@php.net>
Fri, 16 Dec 2011 19:25:03 +0000 (19:25 +0000)
committerXinchen Hui <laruence@php.net>
Fri, 16 Dec 2011 19:25:03 +0000 (19:25 +0000)
sapi/cli/php_cli_server.c
sapi/cli/tests/php_cli_server_015.phpt [new file with mode: 0644]

index 33c37a309bb30180f1cc710fe4ec1323c7482a09..eef0fd500afb642d07eb070d5cfe6119c40403ad 100644 (file)
@@ -1913,6 +1913,7 @@ static int php_cli_server_request_startup(php_cli_server *server, php_cli_server
                destroy_request_info(&SG(request_info));
                return FAILURE;
        }
+       PG(during_request_startup) = 0;
 
        return SUCCESS;
 }
diff --git a/sapi/cli/tests/php_cli_server_015.phpt b/sapi/cli/tests/php_cli_server_015.phpt
new file mode 100644 (file)
index 0000000..9ee7c1b
--- /dev/null
@@ -0,0 +1,49 @@
+--TEST--
+Bug #60523 (PHP Errors are not reported in browsers using built-in SAPI)
+--SKIPIF--
+<?php
+include "skipif.inc"; 
+?>
+--INI--
+display_errors=1
+--FILE--
+<?php
+include "php_cli_server.inc";
+php_cli_server_start('require("syntax_error.php");');
+$dir = realpath(dirname(__FILE__));
+
+file_put_contents($dir . "/syntax_error.php", "<?php non_exists_function(); ?>");
+
+list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
+$port = intval($port)?:80;
+$output = '';
+
+$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
+if (!$fp) {
+  die("connect failed");
+}
+
+if(fwrite($fp, <<<HEADER
+GET /index.php HTTP/1.1
+Host: {$host}
+
+
+HEADER
+)) {
+       while (!feof($fp)) {
+               $output .= fgets($fp);
+       }
+}
+echo $output;
+@unlink($dir . "/syntax_error.php");
+fclose($fp);
+?>
+--EXPECTF--
+HTTP/1.1 200 OK
+Host: %s
+Connection: closed
+X-Powered-By: PHP/%s
+Content-type: text/html
+
+<br />
+<b>Fatal error</b>:  Call to undefined function non_exists_function() in <b>%ssyntax_error.php</b> on line <b>%s</b><br />