ZF-12487: Zend_Config_Yaml does not parse embedded PHP

Issue Type: Bug Created: 2012-12-16T08:58:31.000+0000 Last Updated: 2013-04-05T16:07:06.000+0000 Status: Closed Fix version(s): Reporter: Mike Purcell (bigtruck72) Assignee: None Tags: - Zend_Config

Related issues: Attachments:


In using sfYaml::load($fileUri) I have become accustomed to embedding PHP code, specifically constants, within my Yaml files. Running sfYaml::load natively handles the embedded PHP fine, but when I attempt to use Zend_Config_Yaml with 'decoder' passed in as an option, the embedded PHP code gets treated as a string of text.

After looking at the source code, it appears that line: 169 is the culprit. The file_get_contents call parses the yaml file as a string with no regard to embedded php code, instead it should use output buffering like sfYaml::load() does.


<pre class="highlight">
$config = new Zend_Config_Yaml($fileUri, 'nav', array('yaml_decoder' => array('sfYaml', 'load')));

$nav = new Zend_Navigation($config);


<pre class="highlight">

array (size=1)
  'nav' => 
    array (size=2)
      'Admin' => 
        array (size=5)
          'groups' => string '<?php echo UserPlugin_Api_Group::ID_ADMIN . PHP_EOL ?>' (length=54)
          'render_if' => string 'logged_in' (length=9)
          'label' => string 'Admin' (length=5)
          'uri' => string '@fakeUri' (length=8)
          'pages' => 

Notice the 'groups' line, instead of: 'groups' => string '', it should read: 'groups' => int '1'

To maintain the ability to parse embedded PHP code, I'd suggest adding a check to see if the yamlDecoder === array(CLASS, 'decode'), if so, then use file_get_contents, if not let the passed in callback handle the parsing of the yaml file.


Posted by Ralph Schindler (ralph) on 2013-04-05T16:07:06.000+0000

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit:

Have you found an issue?

See the Overview section for more details.


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

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