php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50142 parse_ini_file() constants not used correctly
Submitted: 2009-11-10 19:44 UTC Modified: 2009-11-11 14:01 UTC
From: jparneodo at yahoo dot fr Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 5.2.11 OS: Ubuntu
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: jparneodo at yahoo dot fr
New email:
PHP Version: OS:

 

 [2009-11-10 19:44 UTC] jparneodo at yahoo dot fr
Description:
------------
Item THREE has bad value.

Input file /tmp/jp.ini:

[CONSTANT]
ONE = "1"
TWO = "2." ONE
THREE = "bug." TWO ONE


Reproduce code:
---------------
<?php
var_dump($ini1=parse_ini_file('/tmp/jp.ini',true));
define('ONE',$ini1['CONSTANT']['ONE']);
echo sprintf("ONE=%s\n",ONE);

var_dump($ini2=parse_ini_file('/tmp/jp.ini',true));
define('TWO',$ini2['CONSTANT']['TWO']);
echo sprintf("ONE=%s TWO=%s\n",ONE,TWO);

var_dump($ini3=parse_ini_file('/tmp/jp.ini',true));
define('THREE',$ini3['CONSTANT']['THREE']);
echo sprintf("ONE=%s TWO=%s THREE=%s\n",ONE,TWO,THREE);


Expected result:
----------------
array(1) {
  ["CONSTANT"]=>
  array(3) {
    ["ONE"]=>
    string(1) "1"
    ["TWO"]=>
    string(5) "2.ONE"
    ["THREE"]=>
    string(9) "bug.TWO ONE"
  }
}
ONE=1
array(1) {
  ["CONSTANT"]=>
  array(3) {
    ["ONE"]=>
    string(1) "1"
    ["TWO"]=>
    string(3) "2.1"
    ["THREE"]=>
    string(9) "bug.TWO ONE"
  }
}
ONE=1 TWO=2.1
array(1) {
  ["CONSTANT"]=>
  array(3) {
    ["ONE"]=>
    string(1) "1"
    ["TWO"]=>
    string(3) "2.1"
    ["THREE"]=>
    string(9) "bug.2.1"
  }
}
ONE=1 TWO=2.1 THREE=bug.2.1


Actual result:
--------------
array(1) {
  ["CONSTANT"]=>
  array(3) {
    ["ONE"]=>
    string(1) "1"
    ["TWO"]=>
    string(5) "2.ONE"
    ["THREE"]=>
    string(9) "bug.TWO ONE"
  }
}
ONE=1
array(1) {
  ["CONSTANT"]=>
  array(3) {
    ["ONE"]=>
    string(1) "1"
    ["TWO"]=>
    string(3) "2.1"
    ["THREE"]=>
    string(9) "bug.TWO ONE"
  }
}
ONE=1 TWO=2.1
array(1) {
  ["CONSTANT"]=>
  array(3) {
    ["ONE"]=>
    string(1) "1"
    ["TWO"]=>
    string(3) "2.1"
    ["THREE"]=>
    string(9) "bug.TWO ONE"
  }
}
ONE=1 TWO=2.1 THREE=c.TWO ONE


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-11 00:13 UTC] fa@php.net
What PHP version gave you your "expected result"?

With 5.2.6 I get this last line:
ONE=1 TWO=2.1 THREE=bug.TWO ONE

With 5.3.1-RC I get this:
ONE=1 TWO=2.1 THREE=bug.2.1 1

With 5.2.11 I get this:
ONE=1 TWO=2.1 THREE=bug.TWO ONE
 [2009-11-11 13:41 UTC] jparneodo at yahoo dot fr
None of 5.2 versions tried has the correct value.

And yes, the correct expected value is:
ONE=1 TWO=2.1 THREE=bug.2.1 1
 [2009-11-11 14:01 UTC] jani@php.net
So it's fixed in (feature added) in 5.3, won't fix (add the feature) for 5.2.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 20:01:32 2024 UTC