ZF-2843: Warning: array_merge_recursive(): recursion detected in Zend\Config\Ini.php on line 134

Issue Type: Bug Created: 2008-03-10T11:44:22.000+0000 Last Updated: 2008-03-21T17:56:47.000+0000 Status: Resolved Fix version(s): - 1.5.1 (25/Mar/08)

Reporter: EV (evalder) Assignee: Rob Allen (rob) Tags: - Zend_Config

Related issues: Attachments:


While trying to figure out how Zend_Config_Ini deals with invalid ini-files, I stumbled upon this error message: {quote} Warning: array_merge_recursive() [function.array-merge-recursive]: recursion detected in [...]Zend\Config\Ini.php on line 134 {quote}

I can't figure out why this happens, but I can reproduce it.

Notice that there are no sections in the config file.


<pre class="highlight">
abc = def

ghi = jkl


<pre class="highlight">

    $myIniConfig = new Zend_Config_Ini('./config.ini', null, array('nestSeparator' => '.'));
catch (Exception $e)
    echo "Could not load configuration - {$e->getMessage()}";

Replacing line 134

<pre class="highlight">
$dataArray = array_merge_recursive($dataArray, $this->_processKey($config, $sectionName, $sectionData));

with the following code

<pre class="highlight">
$tmp = $this->_processKey($config, $sectionName, $sectionData);
$dataArray = array_merge_recursive($dataArray, $tmp);

seems to take care of it for whatever reason, but I still can't tell exactly why it happens so I'm not sure how to properly fix it.

Maybe this is a problem with PHP function array_merge_recursive() - I don't know.

A somewhat related issue, perhaps better suited for a mailing list than here, but I'm lazy.. While trying to debug this issue, I found it a little hard to figure out the meaning of a lot of code in Zend\Config\Ini.php.. For example, why is the $config variable being used as a parameter for a call to $this->_processKey() on that line (134)? That variable holds settings that may be passed to Zend_Config_Ini to configure allowModifications and nestSeparator, so why did it suddenly change its purpose? Or is it really supposed to do that? The result is that you can use $myIniConfig->nestSeparator or $myIniConfig->allowModifications (using $myIniConfig from my reproduction code above) to get those internal settings the same way you would get settings from the parsed ini file, I assume that this is not the intented behaviour.. (shouldn't only settings from the ini file be available as object members like that)?

I see that method _processKey() uses its own variable named $config, maybe that's what caused the confusion (assuming I'm not the one who's confused, but that may very well be a wrong assumption ;-))?

I guess that somewhere between the lines here I'm saying that it could be helpful with more code comments where it's not immediately obvious what's happening, just in case someone else are going to maintain the package sometime in the distant future.. I for one feel that I've spent far too much time on nothing trying to debug this thing, but it might have been a lot easier if it were easier to read what was going on.


Posted by Rob Allen (rob) on 2008-03-10T16:56:58.000+0000


You are right. I've fixed the actual bug by renaming the constructor parameter to $options.

This is committed to trunk in svn r8741.

I will open a separate issue to refactor Zend_Config_Ini to make it more understandable.



Posted by Rob Allen (rob) on 2008-03-10T16:59:05.000+0000

Fixed. I've opened for improving the internals of Zend_Config_Ini.

Posted by Rob Allen (rob) on 2008-03-10T17:11:43.000+0000


Do you want me to apply to branch/release-1.5/ ?

Posted by Darby Felton (darby) on 2008-03-12T14:32:03.000+0000

Yes, but please wait until after code freeze has been announced as lifted. Thanks! :)

Posted by Wil Sinclair (wil) on 2008-03-21T17:19:05.000+0000

I'm assuming this fix is merged to the 1.5 release branch for release with 1.5.1. Please update JIRA if this is not the case.

Posted by Rob Allen (rob) on 2008-03-21T17:56:47.000+0000

It is now!

Sorry - I had it ready to go locally, but forgot to commit after 1.5.0 was released.


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.