Bug #68002 [NEW]: GMP throwing warnings for invalid numbers

From: Date: Wed, 10 Sep 2014 19:01:51 +0000
Subject: Bug #68002 [NEW]: GMP throwing warnings for invalid numbers
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187511@lists.php.net to get a copy of this message
From:             Rican7 at gmail dot com
Operating system: CentOS
PHP version:      5.6.0
Package:          GNU MP related
Bug Type:         Bug
Bug description:GMP throwing warnings for invalid numbers

Description:
------------
Prior to PHP 5.6, you could pass a non-numeric string to gmp_init()
and it would simply return false, allowing you to handle any bad input
errors yourself with a boolean check.

Since the changes to GMP in PHP 5.6, gmp_init() will throw an
uncatchable warning: "Unable to convert variable to GMP - string is not
an integer".

Now, when writing libraries that use GMP, the library has to duplicate
the internal validations to avoid throwing an error.

This would be ok if there was some sort of public API for the GMP
validation, but there isn't.

Test script:
---------------
$gmp = gmp_init('doge'); // Throws warning on 5.6

Expected result:
----------------
$gmp = gmp_init('doge');
var_dump($gmp); // yields "bool(false)"

Actual result:
--------------
$gmp = gmp_init('doge'); // Throws warning
var_dump($gmp); // yields "bool(false)"

-- 
Edit bug report at https://bugs.php.net/bug.php?id=68002&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=68002&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=68002&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=68002&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=68002&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=68002&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=68002&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=68002&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=68002&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=68002&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=68002&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=68002&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=68002&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=68002&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68002&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=68002&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=68002&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=68002&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68002&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=68002&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=68002&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#187511) next »