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
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)