Bug->Req #72578 [Opn]: parse_ini_string() doesn't store extension/zend_extension entries correctly

From: Date: Mon, 11 Jul 2016 19:36:05 +0000
Subject: Bug->Req #72578 [Opn]: parse_ini_string() doesn't store extension/zend_extension entries correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202210@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72578&edit=1

 ID:                 72578
 Updated by:         requinix@php.net
 Reported by:        kurt dot newman at cpanel dot net
 Summary:            parse_ini_string() doesn't store
                     extension/zend_extension entries correctly
 Status:             Open
-Type:               Bug
+Type:               Feature/Change Request
-Package:            Unknown/Other Function
+Package:            Filesystem function related
 Operating System:   Linux
 PHP Version:        7.0.8
 Block user comment: N
 Private report:     N

 New Comment:

Your repro script is far more complicated than it needs to be...
  print_r(parse_ini_string("extension = foo.so\nextension = bar.so"));

php.ini is the weird one here, using duplicate names for loading extensions. Highly unusual for an
INI file - but its reason for doing so makes sense. parse_ini_string is handling the duplicates the
same way that nearly every other INI scanner out there does: overwrite.

So really what you're asking for is an option to allow duplicates, right? To put multiple
values into an array (wouldn't be that name+counter format) without having to use the []
syntax.


Previous Comments:
------------------------------------------------------------------------
[2016-07-11 19:12:46] kurt dot newman at cpanel dot net

Description:
------------
---
From manual page: http://www.php.net/function.parse-ini-string
---

This impacts PHP versions: 5.4.45, 5.5.37, 5.6.23, and 7.0.8.

The documentation does not say that ini entries will be missing and should be considered a bug.  The
documentation says:

   parse_ini_string() returns the settings in string ini in an associative array.


As such, this function doesn't properly parse a PHP ini string AND return the complete settings
described in said string within a resulting associative array.

Test script:
---------------
<?php
    # How to duplicate
    # echo -e "extension = foo.so\nextension = bar.so\n" > foo.ini
    # cat foo.ini | ./thisscript.php

    $ini   = "";
    $stdin = fopen('php://stdin', 'r');

    while (($line = fgets($stdin)) != false)
        $ini .= $line;

    fclose($stdin);

    if (!($arr = parse_ini_string($ini, true, INI_SCANNER_RAW))) {
        fwrite(STDERR, "ERROR: Invalid php ini format\n");
        exit(1);
    }

    print_r( $arr );

    exit(0);
?>

Expected result:
----------------
Recognize that the 'extension' and 'zend_extension' ini entries are special, and
can be duplicated within an ini file.  Perhaps consider placing them in some special place so that
this information isn't lost.

This is just an example, and not a request to use this specific output:

Array
(
   [extension] => Array
       (
          [extension0] => foo.so
          [extension1] => bar.so
       )
)

Actual result:
--------------
# Observe that "foo.so" was defined in the example noted in
# the 'Test script', but is missing in the actual usage.

Array
(
    [extension] => bar.so
)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72578&edit=1


Thread (6 messages)

« previous php.bugs (#202210) next »