Bug #54109 [Opn->Ver]: display_errors setting causes unwanted changes in errors reported
| From: | dtajchreber@php.net | Date: | Sun, 27 Feb 2011 14:24:44 +0000 |
| Subject: | Bug #54109 [Opn->Ver]: display_errors setting causes unwanted changes in errors reported | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159082@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54109&edit=1
ID: 54109
Updated by: dtajchreber@php.net
Reported by: fake at example dot com
Summary: display_errors setting causes unwanted changes in
errors reported
-Status: Open
+Status: Verified
Type: Bug
Package: *Configuration Issues
Operating System: any
PHP Version: trunk-SVN-2011-02-27 (SVN)
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2011-02-27 03:08:43] fake at example dot com
Description:
------------
Following functions may report E_WARNING when invalid utf8 sequence
detected.
json_encode
htmlspecialchars
htmlentities
However, they only issue the warning if display_errors is OFF.
display_errors should not dictate whether the warning is triggered.
They behave this way because of following dumb logic in source code
if (!PG(display_errors)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid UTF-8 sequence
in argument");
}
ext/standard/html.c php_escape_html_entities_ex
ext/json/json.c json_escape_string
This is more or less a repeat of http://bugs.php.net/bug.php?id=52397
which unfortunately got marked bogus.
Test script:
---------------
ini_set('display_errors', 1);
json_encode("\xFF");
var_dump(error_get_last());
echo "-------\n";
ini_set('display_errors', 0);
json_encode("\xFF");
var_dump(error_get_last());
//these have same problem
//htmlspecialchars("\xFF", ENT_COMPAT, 'utf-8');
//htmlentities("\xFF", ENT_COMPAT, 'utf-8');
Expected result:
----------------
I expect both calls to error_get_last() should not return null. Also, I
should have two entries in my error log.
Actual result:
--------------
First call to error_get_last() returns null, second call works. Only one
message in error log.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54109&edit=1