Req #67331 [Opn]: Have parse_ini_file add empty entries

From: Date: Fri, 23 May 2014 03:53:34 +0000
Subject: Req #67331 [Opn]: Have parse_ini_file add empty entries
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185906@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67331&edit=1 ID: 67331 Updated by: aharvey@php.net Reported by: philip@php.net Summary: Have parse_ini_file add empty entries Status: Open Type: Feature/Change Request Package: *Configuration Issues PHP Version: 5.6.0beta3 Block user comment: N Private report: N New Comment: I spiked a quick patch for this: https://github.com/LawnGnome/php-src/compare/php:93a98202d0e8d0f2bfdf4392a4baf2301e343985...bug67331?expand=1 There's one issue, though, which causes the new test to fail: a bare option on the last line of input isn't parsed. This appears to be an issue somewhere in the lexer and/or parser, as the callback is never called to process the input, but my lexer/parser-fu is not good enough to discern why. Help is needed! Beyond that, we'd have to figure out if we would need to hide this behind an option, given potential BC concerns, although my feeling is that this is safe enough for master. Previous Comments: ------------------------------------------------------------------------ [2014-05-23 02:39:24] philip@php.net Johannes pointed out another example. Python allows the "No value" style, as documented here: https://docs.python.org/3/library/configparser.html#supported-ini-file-structure Also, assigned value for these is worth discussing, as perhaps no value entries should be defined as NULL instead of ""? In that case, the expected results would be: array(3) { ["foo"]=> string(3) "bar" ["auto-refresh"]=> NULL ["baz"]=> string(0) "" } ------------------------------------------------------------------------ [2014-05-22 22:27:16] philip@php.net Description: ------------ MySQL has options (such as "no-auto-rehash") in my.cnf that do not take values. In this case, it's one of the following: no-auto-rehash auto-rehash The parse_ini_* functions ignore these, as they lack an "=". Test script: --------------- philip$ php -r '$s = "foo = bar\nauto-rehash\nbaz ="; var_dump(parse_ini_string($s));' Expected result: ---------------- array(3) { ["foo"]=> string(3) "bar" ["auto-refresh"]=> string(0) "" ["baz"]=> string(0) "" } Actual result: -------------- array(2) { ["foo"]=> string(3) "bar" ["baz"]=> string(0) "" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67331&edit=1

« previous php.bugs (#185906) next »