]> granicus.if.org Git - php/commitdiff
Make serialize precision a configurable option.
authorIlia Alshanetsky <iliaa@php.net>
Thu, 8 May 2003 01:23:21 +0000 (01:23 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 8 May 2003 01:23:21 +0000 (01:23 +0000)
ext/standard/tests/serialize/bug23298.phpt
ext/standard/var.c
main/main.c
main/php_globals.h
php.ini-dist
php.ini-recommended

index 5d1931bd74c61e3d22d8fddeb314e5d2b4842189..a5305cf37c924d805d9001c7b6bc767b1fac2869 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 Bug #23298 (serialize() and floats/doubles)
+--INI--
+serialize_precision=100
 --FILE--
 <?php 
        ini_set('precision', 12);
index 8bd51c54ffffb1a673e29d2f0a6145146f8aba92..b641c8b365bff9469a3db8e9f07556c47cfb2924 100644 (file)
@@ -535,7 +535,7 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va
                                char *s;
                                ulong slen;
 
-                               slen = spprintf(&s, 0, "d:%.100G;", Z_DVAL_PP(struc));
+                               slen = spprintf(&s, 0, "d:%.*G;", PG(serialize_precision), Z_DVAL_PP(struc));
                                smart_str_appendl(buf, s, slen);
                                efree(s);
                                return;
index 155e5742cbb6aa678200f73307526a9bcb711442..bd18864bbe246c814715a75b5079813900302de9 100644 (file)
@@ -296,6 +296,7 @@ PHP_INI_BEGIN()
        STD_PHP_INI_BOOLEAN("y2k_compliance",           "1",            PHP_INI_ALL,            OnUpdateBool,                   y2k_compliance,                 php_core_globals,       core_globals)
 
        STD_PHP_INI_ENTRY("unserialize_callback_func",  NULL,   PHP_INI_ALL,            OnUpdateString,                 unserialize_callback_func,      php_core_globals,       core_globals)
+       STD_PHP_INI_ENTRY("serialize_precision",        "100",  PHP_INI_ALL,            OnUpdateLong,                   serialize_precision,    php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("arg_separator.output",       "&",            PHP_INI_ALL,            OnUpdateStringUnempty,  arg_separator.output,   php_core_globals,       core_globals)
        STD_PHP_INI_ENTRY("arg_separator.input",        "&",            PHP_INI_SYSTEM|PHP_INI_PERDIR,  OnUpdateStringUnempty,  arg_separator.input,    php_core_globals,       core_globals)
 
index 29c5103413c85c4241db6f2fa63da0e789256cfd..6665d93280bb095c335582dcdbee3b01dc34b2e0 100644 (file)
@@ -69,6 +69,7 @@ struct _php_core_globals {
        char *output_handler;
 
        char *unserialize_callback_func;
+       long serialize_precision;
 
        char *safe_mode_exec_dir;
 
index de61d45ed1af9f4434ef79de560200273675d1b0..994dc0e956d7157c87add6d0c4697b994ad12b6a 100644 (file)
@@ -137,6 +137,11 @@ implicit_flush = Off
 ; callback-function.
 unserialize_callback_func=
 
+; When floats & doubles are serialized store serialize_precision significant
+; digits after the floating point. The default value ensures that when floats
+; are decoded with unserialize, the data will remain the same.
+serialize_precision = 100
+
 ; Whether to enable the ability to force arguments to be passed by reference
 ; at function call time.  This method is deprecated and is likely to be
 ; unsupported in future versions of PHP/Zend.  The encouraged method of
index 9e5650fcc4a411e94105bb640ea8caa8e84b297c..5ebd39494b0212e4a752340d471f3a283a4e8dad 100644 (file)
@@ -150,6 +150,11 @@ implicit_flush = Off
 ; callback-function.
 unserialize_callback_func=
 
+; When floats & doubles are serialized store serialize_precision significant
+; digits after the floating point. The default value ensures that when floats
+; are decoded with unserialize, the data will remain the same.
+serialize_precision = 100
+
 ; Whether to enable the ability to force arguments to be passed by reference
 ; at function call time.  This method is deprecated and is likely to be
 ; unsupported in future versions of PHP/Zend.  The encouraged method of