summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-05-08 01:23:21 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-05-08 01:23:21 +0000
commitb20df54af7e3cbb016379b42be1f22d8b7ddbf9d (patch)
tree13c2f72ee80122292e0e00b27111dd461e268476
parent7a0efe828afde3d13f1deb8e1dc12ca2e1be12d6 (diff)
downloadphp-git-b20df54af7e3cbb016379b42be1f22d8b7ddbf9d.tar.gz
Make serialize precision a configurable option.
-rw-r--r--ext/standard/tests/serialize/bug23298.phpt2
-rw-r--r--ext/standard/var.c2
-rw-r--r--main/main.c1
-rw-r--r--main/php_globals.h1
-rw-r--r--php.ini-dist5
-rw-r--r--php.ini-recommended5
6 files changed, 15 insertions, 1 deletions
diff --git a/ext/standard/tests/serialize/bug23298.phpt b/ext/standard/tests/serialize/bug23298.phpt
index 5d1931bd74..a5305cf37c 100644
--- a/ext/standard/tests/serialize/bug23298.phpt
+++ b/ext/standard/tests/serialize/bug23298.phpt
@@ -1,5 +1,7 @@
--TEST--
Bug #23298 (serialize() and floats/doubles)
+--INI--
+serialize_precision=100
--FILE--
<?php
ini_set('precision', 12);
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 8bd51c54ff..b641c8b365 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -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;
diff --git a/main/main.c b/main/main.c
index 155e5742cb..bd18864bbe 100644
--- a/main/main.c
+++ b/main/main.c
@@ -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)
diff --git a/main/php_globals.h b/main/php_globals.h
index 29c5103413..6665d93280 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -69,6 +69,7 @@ struct _php_core_globals {
char *output_handler;
char *unserialize_callback_func;
+ long serialize_precision;
char *safe_mode_exec_dir;
diff --git a/php.ini-dist b/php.ini-dist
index de61d45ed1..994dc0e956 100644
--- a/php.ini-dist
+++ b/php.ini-dist
@@ -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
diff --git a/php.ini-recommended b/php.ini-recommended
index 9e5650fcc4..5ebd39494b 100644
--- a/php.ini-recommended
+++ b/php.ini-recommended
@@ -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