From: Operating system: Ubuntu 9.10 PHP version: Irrelevant Package: *Languages/Translation Bug Type: Bug Bug description:MessageFormatter::__construct should throw an exception for invalid patterns
Description: ------------ MessageFormatter's constructor returns NULL when an invalid pattern is given. Instead, it should throw an exception. This bug has already been reported twice before (see #52042 & #49161). Each time the report was marked as bogus because the real problem got overlooked. (the problem lies not in the given pattern being considered invalid by ICU, the problem is in the constructor returning NULL) Test script: --------------- <?php $f1 = msgfmt_create('en_US', '{this was made intentionally incorrect}'); echo 'f1 is ', gettype($f1), PHP_EOL; $f2 = MessageFormatter::create('en_US', '{this was made intentionally incorrect}'); echo 'f2 is ', gettype($f2), PHP_EOL; $f3 = new MessageFormatter('en_US', '{this was made intentionally incorrect}'); echo 'f3 is ', gettype($f3), PHP_EOL; ?> Expected result: ---------------- f1 is NULL f2 is NULL Fatal error: Uncaught exception 'Exception' with message 'Invalid pattern' in %s:%d. Actual result: -------------- f1 is NULL f2 is NULL f3 is NULL -- Edit bug report at http://bugs.php.net/bug.php?id=52776&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52776&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52776&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52776&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52776&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52776&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52776&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52776&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52776&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52776&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52776&r=support Expected behavior: http://bugs.php.net/fix.php?id=52776&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52776&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52776&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52776&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52776&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52776&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52776&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52776&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52776&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52776&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52776&r=mysqlcfg