From:
Operating system: any
PHP version: trunk-SVN-2011-02-27 (SVN)
Package: *Configuration Issues
Bug Type: Bug
Bug description:display_errors setting causes unwanted changes in errors
reported
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 bug report at http://bugs.php.net/bug.php?id=54109&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54109&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54109&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54109&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54109&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54109&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54109&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54109&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54109&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54109&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54109&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54109&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54109&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54109&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54109&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54109&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54109&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54109&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54109&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54109&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54109&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54109&r=mysqlcfg