ZF-11116: A bug report with a correction.

Issue Type: Bug Created: 2011-02-25T12:27:05.000+0000 Last Updated: 2012-03-09T17:31:38.000+0000 Status: Resolved Fix version(s): - Next Major Release ()

Reporter: Cédric Tailly (cedrictailly) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Application

Related issues: Attachments:



I met a bug on Zend Framework 1.11.3 while using Zend_Config_Writer_Array::write().

This method generates a PHP file containing an array() with all data from an ini file, here is the code from my "public/index.php" :

$config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini"); $writer = new Zend_Config_Writer_Array(array("config" => $config, "filename" => $cache_filename)); $writer->write();

In fact, my idea is to create a compiled PHP structure to prevent parsing the "application.ini" file at each execution, next to this I created the Zend_Application with this parameters :

$application = new Zend_Application( APPLICATION_ENV, $cache_filename );

With this code, I have an exception on the default controllers directory wich was not defined.

This is caused by an issue on the Zend_Application class at line 404, the 'php'/'inc' case return the config structure without taking account of the $environment variable (contrary to the other cases, indirectly by $config->toArray() at line 410), this gives an array incompatible with the rest of the process.

So the only fix I made on my side was at line 404 :

return $config[$environment];

All seems to be ok on my version since this modification.

Best regards, Cédric Tailly


Posted by Adam Lundrigan (adamlundrigan) on 2011-05-01T02:58:25.000+0000

Your fix makes the assumption that the configuration file is subdivided internally by the possible values of APPLICATION_ENV, which is not always the case. If you are using the php/inc suffix on your configuration files then Zend_Application assumes you will create a separate file for each value of APPLICATION_ENV and pass in the proper filename at runtime.

That said, making this change would likely break backwards-compatibility for existing applications, so I would suggest bringing this issue up with the maintainer of Zend_Application (or it's successor) in ZF 2.0 to see if it can be addressed there.

Posted by Adam Lundrigan (adamlundrigan) on 2012-03-09T17:31:38.000+0000

Ability to cache parsed configuration files has been added to ZF2

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.