Doc #64090 [NEW]: Normalizer::normalize silently eats data when there is an error
| From: | T dot J dot Hunt at open dot ac dot uk | Date: | Mon, 28 Jan 2013 23:44:07 +0000 |
| Subject: | Doc #64090 [NEW]: Normalizer::normalize silently eats data when there is an error | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-9490@lists.php.net to get a copy of this message | ||
From: T dot J dot Hunt at open dot ac dot uk
Operating system:
PHP version: 5.3.21
Package: Unicode Engine related
Bug Type: Documentation Problem
Bug description:Normalizer::normalize silently eats data when there is an error
Description:
------------
---
From manual page: http://www.php.net/normalizer.normalize#refsect1-
normalizer.normalize-returnvalues
---
"Return Values: The normalized string or NULL if an error occurred."
There are several issues here:
1. what errors might possibly occur? Please can the documentation explain.
2. if an error occurs, then is there any way to get an error message? I
can't see
one.
3. It is very tempting to write code like: $string =
normalizer_normalize($string,
Normalizer::FORM_C); and imagine that it cannot possibly do any harm. Of
course,
that would be naive. one must save the return value into another variable,
and
then explicitly test for NULL. I consider myself a fairly experienced PHP
developer, and I managed to screw this up:
https://moodle.org/mod/forum/discuss.php?d=220722
Anyway, these issues make this API a real pain to work-with. Could we have
a
version of this function that either returns the normalised string, or
throws an
exception?
Test script:
---------------
$string = "Well, I don't know actually. I have no idea what inputs may
cause an error. The documentation does not say"; // Change this line as
necessary to trigger the problem.
$string = normalizer_normalize($string, Normalizer::FORM_C);
if (!$string) {
throw new Exception("Ha! Ha! All your data has been lost.);
}
echo $string;
Expected result:
----------------
Input string is output.
Actual result:
--------------
Well, if you can find some suitable problematic input, then the actual
result of
the test script will be an exception. However, I cannot trigger it myself.
One
user of Moodle seems to have triggered it with the input string "July". See
https://moodle.org/mod/forum/discuss.php?d=220722.
--
Edit bug report at https://bugs.php.net/bug.php?id=64090&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64090&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64090&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64090&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64090&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64090&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64090&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64090&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64090&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64090&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64090&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64090&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64090&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64090&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64090&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64090&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64090&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64090&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64090&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64090&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64090&r=mysqlcfg