php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41922 ini_get() gives ambiguous result
Submitted: 2007-07-08 11:44 UTC Modified: 2007-07-08 15:19 UTC
From: zoe at uk dot ibm dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5CVS-2007-07-08 (CVS) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zoe at uk dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-07-08 11:44 UTC] zoe at uk dot ibm dot com
Description:
------------
The manual states "Returns the value of the configuration option as a string on success, or an empty string on failure"

Some options (eg docref_ext, disable_classes) have default values of an empty string, in these cases ini_get() will return an empty string when the function has failed AND when it has succeeded.

The problem is in the following code:
ZEND_API char *zend_ini_string(char *name, uint name_length, int orig)
{
        zend_ini_entry *ini_entry;
        TSRMLS_FETCH();
 
        if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry)==SUCCESS) {
                if (orig && ini_entry->modified) {
                        return ini_entry->orig_value;
                } else {
                        return ini_entry->value;
                }
        }
 
        return "";
}



Reproduce code:
---------------
Here is a test that will always pass even when ini_get fails.
--TEST--
ini_get returns value of the configuration option as a string on success, empty string on failure
--FILE--
<?php
var_dump(ini_get("disable_classes"));
?>
--EXPECT--
string(0) ""





Expected result:
----------------
I would like to be able to see a failure - if ini_get() fails. For example ini_get() could return FALSE on failure (as ini_set() does), if there are no configuration options that have a default value of FALSE.

Actual result:
--------------
Always a null string.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-08 15:19 UTC] iliaa@php.net
While this is a good idea, unfortunately it would introduce API break 
and likely break many apps that utilize this function. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 08 09:01:33 2024 UTC