summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bcmath/bcmath.c6
-rw-r--r--ext/bcmath/tests/bcscale_variation003.phpt8
2 files changed, 13 insertions, 1 deletions
diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c
index f20dda534f..95b820e4c4 100644
--- a/ext/bcmath/bcmath.c
+++ b/ext/bcmath/bcmath.c
@@ -542,7 +542,11 @@ PHP_FUNCTION(bcscale)
RETURN_THROWS();
}
- BCG(bc_precision) = (int) new_scale;
+ zend_string *ini_name = zend_string_init("bcmath.scale", sizeof("bcmath.scale") - 1, 0);
+ zend_string *new_scale_str = zend_long_to_str(new_scale);
+ zend_alter_ini_entry(ini_name, new_scale_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
+ zend_string_release(new_scale_str);
+ zend_string_release(ini_name);
}
RETURN_LONG(old_scale);
diff --git a/ext/bcmath/tests/bcscale_variation003.phpt b/ext/bcmath/tests/bcscale_variation003.phpt
index b1c541644c..0812aadab6 100644
--- a/ext/bcmath/tests/bcscale_variation003.phpt
+++ b/ext/bcmath/tests/bcscale_variation003.phpt
@@ -6,13 +6,21 @@ bcscale() return value
bcmath.scale=0
--FILE--
<?php
+var_dump((int) ini_get('bcmath.scale'));
var_dump(bcscale(1));
+var_dump((int) ini_get('bcmath.scale'));
var_dump(bcscale(4));
+var_dump((int) ini_get('bcmath.scale'));
var_dump(bcscale());
+var_dump((int) ini_get('bcmath.scale'));
var_dump(bcscale());
?>
--EXPECT--
int(0)
+int(0)
+int(1)
int(1)
int(4)
int(4)
+int(4)
+int(4)