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

Description

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.


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;
        unset($options['keepLayouts']);
//      $encodeData  = (array_key_exists('encodeData', $keepLayouts))
//                      ? $keepLayouts['encodeData']
        $encodeData  = (array_key_exists('encodeData', $options))
                        ? $options['encodeData']
                        : $encodeData;
        unset($options['encodeData']);
    }

Comments

Patch and unit test added.

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