ZF-11814: Remember meta info (link file name and line number) per config option

Issue Type: Improvement Created: 2011-10-11T11:04:07.000+0000 Last Updated: 2012-04-28T16:22:04.000+0000 Status: Open Fix version(s): Reporter: monk e boy (monk.e.boy) Assignee: None Tags: - Zend_Config

Related issues: Attachments:


I have problems with a navigation.ini file throwing errors, but it is not possible to go from the config option back to the line of the ini file that caused the error:…

Could this info be saved as part of the option?


Posted by Frank Brückner (frosch) on 2011-10-11T15:24:18.000+0000

Hello monk e boy, you never get the line number with the error:

<pre class="highlight">
cms.paes.ntro.lael      = Edit
cms.pags.intr.moule     = admin
cm.pages.into.controler = cms
cms.paes.intro.ation    = editor

This is a correct file, because there is no error in the ini syntax! Zend_Config (parse_ini_file) works without problems.

Only if the ini syntax is wrong, then you get an error:

<pre class="highlight">
cms.pages.intro.label = Edit


<pre class="highlight">
Fatal error: Uncaught exception 'Zend_Config_Exception' with message 'syntax error, unexpected '!' in foo.ini on line 3

So you can see, there is no chance to get a line number, if no syntax error is present.

Posted by monk e boy (monk.e.boy) on 2011-10-12T15:41:22.000+0000

From the example on:…

Why can't I do:

$config = new Zend_Config_Ini('/path/to/config.ini', 'staging');
echo $config->database->params->host; // prints "" echo $config->database->params->dbname; // prints "dbname" // PROPOSED CHANGES: echo $config->database->params->host->meta; // prints "/path/to/config.ini, line 44"

Then this could be used to fix the other bug linked in my first comment.


Posted by monk e boy (monk.e.boy) on 2011-10-12T15:43:03.000+0000

Sorry, I should have mentioned that Zend_Config_Ini would have to save this info somewhere (or calculate it when it's needed)

Posted by Frank Brückner (frosch) on 2011-10-12T16:30:23.000+0000


<pre class="highlight">
Prints the error message:

Notice: Trying to get property of non-object in /…/foo.php on line 9 ```

Posted by monk e boy (monk.e.boy) on 2011-10-14T09:16:00.000+0000

// PROPOSED CHANGES: echo $config->database->params->host->meta; // prints "/path/to/config.ini, line 44"

Look, it's not rocket science. Just store the file name and line number with each item in the Config. I propose the attribute in the config item is called 'meta' but feel free to call it what you like.

As an optimisation you could normalize the data a bit.


Posted by Rob Allen (rob) on 2011-10-14T09:23:40.000+0000

The current operation of Zend_Config is that $config->b doesn't generate any errors if b doesn't exit. (though $config->a->b will do as Frank notes). Any change to this behaviour has to be added as a configurable option as we cannot break B/C on ZF 1.

If we are going to generate an error message on property not found, then it should be an Exception, not an echoed message.

If you have signed the CLA, please provide a patch that meets these criteria.

Posted by Damien Camus (deterred) on 2011-11-14T08:48:11.000+0000

I'm interrested in

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.