php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60523 PHP Errors are not reported in browsers using built-in SAPI
Submitted: 2011-12-14 14:28 UTC Modified: 2011-12-19 10:31 UTC
From: lolautruche at gmail dot com Assigned: moriyoshi (profile)
Status: Closed Package: Built-in web server
PHP Version: 5.4SVN-2011-12-14 (snap) OS: Mac OS X 10.7.2 (Lion)
Private report: No CVE-ID: None
 [2011-12-14 14:28 UTC] lolautruche at gmail dot com
Description:
------------
Hi

Using new built-in SAPI with a router script, if a fatal error occurs (or any 
other notice/warning), it is reported in the PHP webserver log but not to the 
browser.
It makes errors harder to detect.

According to DerickR : "With a router, PG(during_request_startup) isn't set to 0"

Test script:
---------------
- Make a test.php script forcing a fatal error
- Make a router script named router.php, requiring test.php
- Start built-in webserver : php -S localhost:8000 router.php
- Go to http://localhost:8000 with your browser

test.php :
<code>
// Forcing a fatal error
$foo = null;
$foo->bar();
</code>

router.php :
<code>
require_once 'test.php';
</code>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-14 14:49 UTC] derick@php.net
-Status: Open +Status: Analyzed
 [2011-12-14 14:49 UTC] derick@php.net
To follow up on that:

Without the router, php_cli_server_dispatch_script is used and php_execute_script (sapi/cli/php_cli_server.c:1838) is run. With the router, php_cli_server_dispatch_router is used and zend_execute_scripts is run (sapi/cli/php_cli_server.c:1951). The former sets PG(during_request_startup) = 0; but the latter never does. Hence for the whole request, PG(during_request_startup) = 1 as set by php_request_startup in main/main.c:1520. The comment on line 1565 (/* We turn this off in php_execute_script() */) explains why php_execute_script (which wraps zend_execute_scripts, main/main.c:2476) sets it to 0.

The php_cli_server_dispatch_router function should do PG(during_request_startup) = 0 somewhere before it calls zend_execute_scripts (I think).
 [2011-12-14 14:50 UTC] derick@php.net
-Status: Analyzed +Status: Assigned -Assigned To: +Assigned To: moriyoshi
 [2011-12-16 19:24 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=321074
Log: Fixed bug #60523 (PHP Errors are not reported in browsers using built-in SAPI)
 [2011-12-16 19:25 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Moriyoshi, I fix this for you, hope you don't mind, thanks :)
 [2011-12-16 19:25 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2011-12-19 10:31 UTC] lolautruche at gmail dot com
Perfect, thanks !
 [2012-04-18 09:46 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8b16b7bd4b49b31815e2788740f21a7235f7fe09
Log: Fixed bug #60523 (PHP Errors are not reported in browsers using built-in SAPI)
 [2012-07-24 23:38 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8b16b7bd4b49b31815e2788740f21a7235f7fe09
Log: Fixed bug #60523 (PHP Errors are not reported in browsers using built-in SAPI)
 [2013-11-17 09:34 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8b16b7bd4b49b31815e2788740f21a7235f7fe09
Log: Fixed bug #60523 (PHP Errors are not reported in browsers using built-in SAPI)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC