Issues

ZF-10945: new Zend_Application('ENV', array('config' => 'path/to/conf')) does not load externally references configuration files

Description

When passing constructor options to Zend_Application the option exists to feed an array with an config key. This key can either contain a string an an array with strings. This is useful because it allows to feed additional configuration from an external file, overruling the other configuration options that are fed into Zend_Application. A side effect of this is that one can break it configuration into multiple files and have one referencing the other by specifying either an config = path/to/other/config/file (as string) or config[] = path/to/other/config/file (as array) inside the application.ini

However there is a problem with the way Zend_Application handles these cases, resulting that referenced configuration options aren't read.

You can load configuration files in three different ways.

  1. new Zend_Application('ENV', 'path/to/conf');
  2. new Zend_Application('ENV', array('config' => 'path/to/conf'));
  3. new Zend_Application('ENV', array('config' => array('path/to/conf', 'path/to/yet/another/conf')));

The problem is with variant 2; only configuration options inside path/to/conf are read. Any references to other configuration files are omitted. I ran into this problem, because I have my configuration option split among several files. one application.ini that references several resource files. Zend_Tool uses an the second version to get an instance of Zend_Application, resulting that not my complete set of options was available.

Affected version are for sure 1.10.8 till 1.11.2 but presumably earlier ones.

Lead developers stated the following: "It was never really intended. The reason we have it at all was because of a particular use case where developers wanted to provide some defaults via the initial Zend_Application initialization, but still utilize a config file We never intended to allow nesting of configs, to be honest -- that's something I'm hoping we can build into Zend_Config for ZF2 (instead of emulating within Zend_Application)."

However i would really like to see this improvement materialize, so an attached patch adds this capability. It makes sure circular references aren't followed. The order in which the configuration files are loaded stay the same (options read in earlier files aren't overridden by one loaded later. Included in the patch is a unit test. All other tests still run fine.

Comments

This issue is related to http://framework.zend.com/issues/browse/ZF-10548 . But it was suggested the encountered problem does not arise Zend_Tool but in Zend_Application.

However since Zend_Application is unlikely to get modified (because it might have unforeseen consequences) I would rather have this issue closed and 10548 reopened... If the patch mentioned there is applied we can safely work around the problem.

Attached a fixed version of the OP's patch (was not generated from trunk directory)