#42657 [Bgs->Opn]: ini_get returns an unexpected value
| From: | jani@php.net | Date: | Tue, 18 Sep 2007 11:32:38 +0000 |
| Subject: | #42657 [Bgs->Opn]: ini_get returns an unexpected value | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-19@lists.php.net to get a copy of this message | ||
ID: 42657
Updated by: jani@php.net
Reported By: jcortinap at googlemail dot com
-Status: Bogus
+Status: Open
-Bug Type: *Configuration Issues
+Bug Type: Documentation problem
Operating System: Win XP Pro / Win 2003 Server
PHP Version: 5.2.4
-Assigned To:
+Assigned To: jani
New Comment:
Another note: sendmail_from is set to NULL by default (ie. if it's not
set in php.ini, the value for it is NULL -> causes ini_get() to return
false. This should be mentioned in the documentation.
I'm going to fix this for 5.3 (among lot of other issues with ini
handling), so once docs are updated, reassign this back to me.
Previous Comments:
------------------------------------------------------------------------
[2007-09-18 11:04:27] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
http://www.php.net/ini_get says:
"Returns the value of the configuration option as a string on success,
or an empty string on failure or for null values."
So this is expected behavior when an ini option isn't set at all.
------------------------------------------------------------------------
[2007-09-13 12:28:56] jcortinap at googlemail dot com
Description:
------------
This problem was found trying to set the sendmail_from directive from a
script. This directive is intentionally NOT set on the php.ini (it is
commented out).
According to the documentation, ini_get should return an empty string
since the directive is not set, but it returns a boolean false.
When calling ini_set to set the value, it is expected to get the old
value on success or FALSE on failure, and what we experience is that the
setting is correctly set, but FALSE is returned.
My theory is that ini_set is working correctly returning the "old"
value of the setting, but since the old value is being returned as FALSE
from ini_get, this is what we get as a return from ini_set, so the
problem seems to be in the ini_get function.
Tested with the same results on both 4.4.7 and 5.2.4.
Reproduce code:
---------------
// sendmail_from not set in php.ini. This should return an empty
string
$value = ini_get('sendmail_from');
var_dump($value);
// sendmail_from is correctly set, so an empty string should be
returned
$old_value = ini_set('sendmail_from', 'from@example.com');
var_dump($old_value);
// new value of the sendmail_from directive is correctly set
$value = ini_get('sendmail_from');
var_dump($value);
Expected result:
----------------
string(0) ""
string(0) ""
string(16) "from@example.com"
Actual result:
--------------
bool(false)
bool(false)
string(16) "from@example.com"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42657&edit=1