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

Ini config parsed incorrectly when using numeric indexes #12725

Closed
hugofcampos opened this issue Mar 20, 2017 · 6 comments
Closed

Ini config parsed incorrectly when using numeric indexes #12725

hugofcampos opened this issue Mar 20, 2017 · 6 comments
Labels
bug A bug report status: low Low
Milestone

Comments

@hugofcampos
Copy link

hugofcampos commented Mar 20, 2017

We are updgrade a Phalcon 1.* app and, in Phalcon 2.* to 3.0.4, our config files started to load incorrectly.

I'm trying to parse an ini array for logs config with this format:

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

What I expected to see was:

Array
(
    [channel] => Array
        (
            [handlers] => Array
                (
                    [0] => Array
                        (
                            [name] => stream
                            [level] => debug
                            [fingersCrossed] => info
                            [filename] => channel.log
                        )
                    [1] => Array
                        (
                            [name] => redis
                            [level] => debug
                            [fingersCrossed] => info
                        )
                )
        )
)

But this is what I got was:

Array
(
    [channel] => Array
        (
            [handlers] => Array
                (
                    [0] => Array
                        (
                            [name] => stream
                        )

                    [1] => Array
                        (
                            [level] => debug
                        )

                    [2] => Array
                        (
                            [fingersCrossed] => info
                        )

                    [3] => Array
                        (
                            [filename] => channel.log
                        )

                    [4] => Array
                        (
                            [name] => redis
                        )

                    [5] => Array
                        (
                            [level] => debug
                        )

                    [6] => Array
                        (
                            [fingersCrossed] => info
                        )
                )

        )
    )
)

Apparently, integer pieces in string are not creating array indexes. This is a bug or an unsupported format?

# php --ri
phalcon


Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 3.0.4
Build Date => Mar 20 2017 14:43:00
Powered by Zephir => Version 0.9.6a-dev-aef205594b

Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off

# php -v
PHP 5.6.30 (cli) (built: Feb 28 2017 17:36:58)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.5.1, Copyright (c) 2002-2017, by Derick Rethans

# SO version
Debian GNU/Linux 8

Installation type: Compiling from source

Server: Nginx
@gguridi
Copy link
Contributor

gguridi commented Mar 22, 2017

I would consider it an unsupported format.

The example can be done using associative arrays instead:

channel.handlers.stream.name = stream
channel.handlers.stream.level = debug
channel.handlers.stream.fingersCrossed = info
channel.handlers.stream.filename = channel.log
channel.handlers.redis.name = redis
channel.handlers.redis.level = debug
channel.handlers.redis.fingersCrossed = info

Is there any reason why the handlers array should be an indexed array instead of associative? Other config formats support it anyway.

@hugofcampos
Copy link
Author

hugofcampos commented Mar 22, 2017 via email

@sergeyklay
Copy link
Contributor

actually you can try

foo[] = bar

@hugofcampos
Copy link
Author

hugofcampos commented Mar 22, 2017 via email

@sergeyklay sergeyklay added this to the 4.0.0 milestone Mar 22, 2017
@stale
Copy link

stale bot commented Apr 16, 2018

Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues

@stale stale bot added the stale Stale issue - automatically closed label Apr 16, 2018
@sergeyklay sergeyklay reopened this May 2, 2018
@stale stale bot removed the stale Stale issue - automatically closed label May 2, 2018
CameronHall pushed a commit to CameronHall/cphalcon that referenced this issue Nov 19, 2018
CameronHall pushed a commit to CameronHall/cphalcon that referenced this issue Nov 19, 2018
CameronHall pushed a commit to CameronHall/cphalcon that referenced this issue Nov 19, 2018
CameronHall pushed a commit to CameronHall/cphalcon that referenced this issue Nov 19, 2018
CameronHall pushed a commit to CameronHall/cphalcon that referenced this issue Nov 19, 2018
@sergeyklay sergeyklay modified the milestones: 4.0.0, 3.4.1, 3.4.2 Nov 19, 2018
@sergeyklay
Copy link
Contributor

Fixed in the 3.4.x branch. Feel free to open a new issue if the problem appears again. Thank you for contributing.

@niden niden removed the Bug - Low label Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: low Low
Projects
None yet
Development

No branches or pull requests

4 participants