Skip to content

Commit

Permalink
Fixed #12725: Numeric INI config now builds properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Hall authored and sergeyklay committed Nov 19, 2018
1 parent c531d1d commit fdea0ee
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 15 deletions.
2 changes: 1 addition & 1 deletion phalcon/config/adapter/ini.zep
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Ini extends Config
let sections[] = this->_parseIniString((string)path, lastValue);
}
if count(sections) {
let config[section] = call_user_func_array("array_merge_recursive", sections);
let config[section] = call_user_func_array("array_replace_recursive", sections);
}
} else {
let config[section] = this->_cast(directives);
Expand Down
11 changes: 10 additions & 1 deletion tests/_data/config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ name = demo

[test]
parent.property = On
parent.property2 = "yeah"
parent.property2 = "yeah"

[issue-12725]
channel.handlers.0.name = stream
channel.handlers.0.level = debug
channel.handlers.0.fingersCrossed = info
channel.handlers.0.filename = channel.log
channel.handlers.1.name = redis
channel.handlers.1.level = debug
channel.handlers.1.fingersCrossed = info
39 changes: 38 additions & 1 deletion tests/_data/config/config.json
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
{"phalcon":{"baseuri":"\/phalcon\/"},"models":{"metadata":"memory"},"database":{"adapter":"mysql","host":"localhost","username":"user","password":"passwd","name":"demo"},"test":{"parent":{"property":1,"property2":"yeah"}}}
{
"phalcon": {
"baseuri": "/phalcon/"
},
"models": {
"metadata": "memory"
},
"database": {
"adapter": "mysql",
"host": "localhost",
"username": "user",
"password": "passwd",
"name": "demo"
},
"test": {
"parent": {
"property": 1,
"property2": "yeah"
}
},
"issue-12725": {
"channel": {
"handlers": [
{
"name": "stream",
"level": "debug",
"fingersCrossed": "info",
"filename": "channel.log"
},
{
"name": "redis",
"level": "debug",
"fingersCrossed": "info"
}
]
}
}
}
41 changes: 29 additions & 12 deletions tests/_data/config/config.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
<?php

return array(
"phalcon" => array(
return [
"phalcon" => [
"baseuri" => "/phalcon/"
),
"models" => array(
],
"models" => [
"metadata" => "memory"
),
"database" => array(
],
"database" => [
"adapter" => "mysql",
"host" => "localhost",
"username" => "user",
"password" => "passwd",
"name" => "demo"
),
"test" => array(
"parent" => array(
],
"test" => [
"parent" => [
"property" => 1,
"property2" => "yeah"
),
)
);
],
],
'issue-12725' => [
'channel' => [
'handlers' => [
0 => [
'name' => 'stream',
'level' => 'debug',
'fingersCrossed' => 'info',
'filename' => 'channel.log'
],
1 => [
'name' => 'redis',
'level' => 'debug',
'fingersCrossed' => 'info'
]
]
]
]
];
12 changes: 12 additions & 0 deletions tests/_data/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ test:
parent:
property: 1
property2: yeah
issue-12725:
channel:
handlers:
0:
name: stream
level: debug
fingersCrossed: info
filename: channel.log
1:
name: redis
level: debug
fingersCrossed: info
17 changes: 17 additions & 0 deletions tests/unit/Config/Helper/ConfigBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@ class ConfigBase extends UnitTest
'property2' => 'yeah'
],
],
'issue-12725' => [
'channel' => [
'handlers' => [
0 => [
'name' => 'stream',
'level' => 'debug',
'fingersCrossed' => 'info',
'filename' => 'channel.log'
],
1 => [
'name' => 'redis',
'level' => 'debug',
'fingersCrossed' => 'info'
]
]
]
]
];

protected function compareConfig(array $actual, Config $expected)
Expand Down

0 comments on commit fdea0ee

Please sign in to comment.