php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52138 Constants are parsed into the ini file for section names
Submitted: 2010-06-22 09:59 UTC Modified: 2010-06-25 00:32 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: acid24 at gmail dot com Assigned: felipe
Status: Closed Package: Filesystem function related
PHP Version: 5.3.2 OS: Red Hat Enterprise release 5.3
Private report: No CVE-ID:
 [2010-06-22 09:59 UTC] acid24 at gmail dot com
Description:
------------
Documentation at http://www.php.net/manual/en/function.parse-ini-file.php says "Constants may also be parsed in the ini file so if you define a constant as an ini value before running parse_ini_file(), it will be integrated into the results. Only ini values are evaluated.". 

I found this to be incomplete. Not only ini values are evaluated, but also section names.

Test script:
---------------
define( 'MYCONST', 1 );
/*
test.ini file looks like this

[MYCONST]
MYCONST = MYCONST

*/
$ret = parse_ini_file( 'test.ini', true );
var_dump( $ret );

Expected result:
----------------
array(1) {
  ["MYCONST"]=>
  array(1) {
    ["MYCONST"]=>
    string(1) "1"
  }
}

Actual result:
--------------
array(1) {
  [1]=>
  array(1) {
    ["MYCONST"]=>
    string(1) "1"
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-23 02:09 UTC] felipe@php.net
-Status: Open +Status: Analyzed
 [2010-06-23 02:09 UTC] felipe@php.net
For 5.3+ the constant value is passed directly to ZEND_INI_PARSER_CB(), thus not knowing its name...
 [2010-06-23 09:31 UTC] acid24 at gmail dot com
I don't think section names should be replaced by constant values, but since that's the case, the online documentation should be updated to document this fact.
 [2010-06-24 02:31 UTC] felipe@php.net
I should not... as it can cause overwrite.
 [2010-06-25 00:32 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=300737
Log: - Fixed bug #52138 (Constants are parsed into the ini file for section names)
 [2010-06-25 00:32 UTC] felipe@php.net
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: felipe
 [2010-06-25 00:32 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 18:01:58 2014 UTC