Issue Details (XML | Word | Printable)

Key: ZF-6811
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jon Whitcraft
Reporter: Simon Corless
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Zend Application - Merge Config Should Overwrite ini With Array Data?

Created: 26/May/09 02:28 PM   Updated: 13/Nov/09 12:03 AM   Resolved: 09/Nov/09 08:15 AM
Component/s: Zend_Application
Affects Version/s: 1.8.2
Fix Version/s: 1.10.0

Time Tracking:
Not Specified

File Attachments: 1. Text File Zend Application - Config Merge.patch (0.5 kB)



 Description  « Hide

I believe it would be more useful if the config options from an ini file (if specified in the 'config' option) were overwritten by any configuration options supplied as part of the options array in the Zend_Application constructor (i.e. array('resources' => array('option' => 'value'))).

I think the function setOptions(array $options) on line 117 of Zend/Application.php should be altered. Changing it from:

$options = $this->mergeOptions($options, $this->_loadConfig($options['config']));

to:

$options = $this->mergeOptions($this->_loadConfig($options['config']), $options);

I believe the case is stronger to overwrite ini data via the constructor call than it would be in reverse.

Using the following code:

application.ini:
resources.frontController.defaultModule = "content"

index.php:
$application = new Zend_Application(APPLICATION_ENV, array(
'config' => ROOT_PATH . 'application/config/bootstrap/application.ini',
'resources' => array(
'frontController' => array(
'defaultModule' => 'admin'
)
)
));

Causes the defaultModule to be content. I would like the outcome to make the defaultModule admin as specified in the array and not the ini file.



Simon Corless added a comment - 29/May/09 05:02 AM

This appears to have been done in 1.8.2 sorry for not finding the original bug report.


Simon Corless added a comment - 03/Jun/09 02:25 AM

I seem to have jumped the gun a little here and the issue hasn't been resolved in 1.8.2. Can you reset this issue to unresolved?


Jason Brumwell added a comment - 09/Sep/09 09:41 AM

I agree, I am writing a cron portion of a site I'm working on and would like to use the original application config, which has:

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

I would like to update that to my cron bootstrap.php file, through the option settings


Simon Corless added a comment - 09/Sep/09 10:00 AM

This is a patch file to fix the issue, I have never done this before so I don't know the correct way of doing it. It's the patch I use for my local copies of the Framework.

I would really like to see this fixed.


Jon Whitcraft added a comment - 09/Nov/09 08:15 AM

This has been checked into the trunk.


Jon Whitcraft added a comment - 09/Nov/09 08:45 AM

After talking with Matthew about this issue it will not be made available in the 1.9.x cycle as it changes the behavior slightly.

It will be included in the 1.10 release.


Andy Fowler added a comment - 12/Nov/09 03:46 PM

I'd vote for this to enter the 1.9.x cycle. I'm slightly confused on Matthew's stance, because he seems to be endorsing the new behavior in the last example on his article: http://weierophinney.net/matthew/archives/227-Exposing-Service-APIs-via-Zend-Framework.html

(Overriding a .ini config with array data).


Simon Corless added a comment - 13/Nov/09 12:03 AM

I agree, there is a BC break but that BC doesn't work to start with!, considering you can't actually over write anything unless it's not been set in the first place!

Still I'm happy to have it fixed eventually and to stop having to patch my files.