Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #829 fixed for 1.2.1 #837

Merged
merged 4 commits into from Jul 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- 'beforeException' events now can handle exceptions ocurred when executing actions
- Added Phalcon\Dispatcher::getHandlerClass and Phalcon\Dispatch::getActionMethod
- Now Phalcon\Form\Element\* classes implement Phalcon\Form\ElementInterface
- Phalcon\Config\Adapter\Ini correctly handles empty sections and INI files without any sections

1.2.0
- Now 'compiledPath' option accept a closure to dynamically create the compilation path in Volt
Expand Down
2 changes: 1 addition & 1 deletion ext/cache/frontend/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "kernel/main.h"
#include "kernel/memory.h"

#include "kernel/string.h"
#include "kernel/object.h"
#include "kernel/array.h"
#include "kernel/fcall.h"
Expand Down
15 changes: 15 additions & 0 deletions ext/config/adapter/ini.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,23 @@ PHP_METHOD(Phalcon_Config_Adapter_Ini, __construct){
PHALCON_GET_HKEY(section, ah0, hp0);
PHALCON_GET_HVALUE(directives);

if (unlikely(Z_TYPE_P(directives) != IS_ARRAY)) {
Z_ADDREF_P(directives);
if (phalcon_array_update_zval(&config, section, &directives, 0) != SUCCESS) {
Z_DELREF_P(directives);
}
zend_hash_move_forward_ex(ah0, &hp0);
continue;
}

phalcon_is_iterable(directives, &ah1, &hp1, 0, 0);

if (zend_hash_num_elements(ah1) == 0) {
phalcon_array_update_zval(&config, section, &directives, 0);
zend_hash_move_forward_ex(ah0, &hp0);
continue;
}

while (zend_hash_get_current_data_ex(ah1, (void**) &hd, &hp1) == SUCCESS) {

PHALCON_GET_HKEY(key, ah1, hp1);
Expand Down
1 change: 1 addition & 0 deletions ext/http/response.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "kernel/exception.h"
#include "kernel/concat.h"
#include "kernel/operators.h"
#include "kernel/string.h"

/**
* Phalcon\Http\Response
Expand Down
2 changes: 1 addition & 1 deletion ext/logger/formatter/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "kernel/main.h"
#include "kernel/memory.h"

#include "kernel/string.h"
#include "kernel/fcall.h"
#include "kernel/array.h"

Expand Down
23 changes: 22 additions & 1 deletion unit-tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,26 @@ public function testIssue732()
unset($a['a']);
$this->assertTrue(!isset($a['a']));
}
}

public function testIssue829()
{
$config = new \Phalcon\Config\Adapter\Ini('unit-tests/config/829-no-sections.ini');
$actual = $config->toArray();
$expected = array(
'hoge' => 'test',
'foo' => 'bar',
);

$this->assertEquals($actual, $expected);

$config = new \Phalcon\Config\Adapter\Ini('unit-tests/config/829-with-empty-section.ini');
$actual = $config->toArray();
$expected = array(
'section' => array('hoge' => 'test'),
'empty' => array(),
'test' => array('foo' => 'bar'),
);

$this->assertEquals($actual, $expected);
}
}
2 changes: 2 additions & 0 deletions unit-tests/config/829-no-sections.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hoge=test
foo=bar
7 changes: 7 additions & 0 deletions unit-tests/config/829-with-empty-section.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[section]
hoge=test

[empty]

[test]
foo=bar
Empty file modified unit-tests/config/config.ini
100755 → 100644
Empty file.