]> granicus.if.org Git - php/commitdiff
- allow to use "yes" and "true" with ini_set() and in commandline (through -d flag)
authorAntony Dovgal <tony2001@php.net>
Wed, 22 Jun 2005 12:02:47 +0000 (12:02 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 22 Jun 2005 12:02:47 +0000 (12:02 +0000)
- fix #15854 that was caused by wrong consideration that zend_ini_boolean_displayer_cb()
always recieves converted to "0"/"1" values.

NEWS
Zend/zend_ini.c

diff --git a/NEWS b/NEWS
index 54d77cfcf23eb0bc3ba0f55b7487fbbc44b435c6..edde30249ea82df9003c62f6f4d4276eee349c4d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP                                                                        NEWS
 - Fixed bug #33427 (ext/odbc: check if unixODBC header file exists). (Jani)
 - Fixed bug #33257 (array_splice() inconsistent when passed function instead
   of variable). (Dmitry)
+- Fixed bug #15854 (boolean ini options may be incorrectly displayed as Off 
+  when they are On). (Tony)
 
 21 Jun 2005, PHP 5.1 Beta 2
 - Improved PHP extension loading mechanism with support for module dependencies
index aedc1e14ad16faedd445f4863809874554bd7ae7..3de2f8de0c2fc7b4a8069f5884fd573c9968e31f 100644 (file)
@@ -371,15 +371,33 @@ static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
 
 ZEND_INI_DISP(zend_ini_boolean_displayer_cb)
 {
-       int value;
+       int value, tmp_value_len;
+       char *tmp_value;
 
        if (type==ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
-               value = (ini_entry->orig_value ? atoi(ini_entry->orig_value) : 0);
+               tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
+               tmp_value_len = ini_entry->orig_value_length;
        } else if (ini_entry->value) {
-               value = atoi(ini_entry->value);
+               tmp_value = ini_entry->value;
+               tmp_value_len = ini_entry->value_length;
        } else {
-               value = 0;
+               tmp_value = NULL;
+               tmp_value_len = 0;
        }
+
+       if (tmp_value_len == 4 && strcasecmp(tmp_value, "true") == 0) {
+               value = 1;
+       }
+       else if (tmp_value_len == 3 && strcasecmp(tmp_value, "yes") == 0) {
+               value = 1;
+       }
+       else if (tmp_value_len == 2 && strcasecmp(tmp_value, "on") == 0) {
+               value = 1;
+       }
+       else {
+               value = atoi(tmp_value);
+       }
+       
        if (value) {
                ZEND_PUTS("On");
        } else {
@@ -452,9 +470,16 @@ ZEND_API ZEND_INI_MH(OnUpdateBool)
 
        p = (zend_bool *) (base+(size_t) mh_arg1);
 
-       if (new_value_length==2 && strcasecmp("on", new_value)==0) {
+       if (new_value_length==2 && strcasecmp("on", new_value)==0) {
                *p = (zend_bool) 1;
-       } else {
+       } 
+       else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
+               *p = (zend_bool) 1;
+       } 
+       else if (new_value_length==4 && strcasecmp("true", new_value)==0) {
+               *p = (zend_bool) 1;
+       } 
+       else {
                *p = (zend_bool) atoi(new_value);
        }
        return SUCCESS;