ZF-12397: Zend_View_Helper_Json handles $keepLayouts argument as array incorrectly

Issue Type: Bug Created: 2012-08-31T13:36:26.000+0000 Last Updated: 2012-11-07T19:58:53.000+0000 Status: Resolved Fix version(s): - 1.12.1 (18/Dec/12)

Reporter: Rob McClain (celeron450) Assignee: Frank Brückner (frosch) Tags: - Zend_View

  • FixForZF1.12.1

Related issues: - ZF-12410

Attachments: - Json.php.patch


If $keepLayouts is passed as an array, Zend_View_Helper_Json::json does not properly use the encodeData key from the array. Additionally, it causes a "Warning: [2] array_key_exists() expects parameter 2 to be array, boolean given". It should check $options for the array key instead of $keepLayouts.

<pre class="highlight">
public function json($data, $keepLayouts = false, $encodeData = true)
    $options = array();
    if (is_array($keepLayouts))
        $options     = $keepLayouts;
//      $keepLayouts = (array_key_exists('keepLayouts', $keepLayouts))
//                      ? $keepLayouts['keepLayouts']
        $keepLayouts = (array_key_exists('keepLayouts', $options))
                        ? $options['keepLayouts']
                        : false;
//      $encodeData  = (array_key_exists('encodeData', $keepLayouts))
//                      ? $keepLayouts['encodeData']
        $encodeData  = (array_key_exists('encodeData', $options))
                        ? $options['encodeData']
                        : $encodeData;


Posted by Frank Brückner (frosch) on 2012-08-31T15:17:10.000+0000

Patch and unit test added.

Posted by Rob Allen (rob) on 2012-11-07T19:58:53.000+0000

Applied patch to trunk (25090) and release-1.12 (25091)

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.