[TYPO3-core] RFC: Bug 5288: Missing parameter in recursion of t3lib_div::array_merge_recursive_overrule

Ingmar Schlecht ingmar at typo3.org
Wed Mar 28 14:48:38 CEST 2007


+1 based on reading the patch.

cheers
ingmar

Oliver Hader schrieb:
> This is a SVN patch request.
> 
> Problem:
> The function t3lib_div::array_merge_recursive_overrule recursivly merges
> 2 arrays. The recursion however does not pass the optional 4th parameter
> so that using the function on a mutlidimensional array ignores the
> setting of $includeEmtpyValues. In this case $includeEmtpyValues is
> always true even if the method was initially called with
> $includeEmtpyValues set to false.
> 
> Solution:
> Use $includeEmtpyValues on recursive calls.
> 
> Comments:
> Thanks to Simon Tuck for providing a fix.
> 
> Bugtracker references:
> http://bugs.typo3.org/view.php?id=5288
> 
> Branches: Trunk & TYPO3-4_1
> 
> 
> olly
> 
> 
> ------------------------------------------------------------------------
> 
> Index: t3lib/class.t3lib_div.php
> ===================================================================
> --- t3lib/class.t3lib_div.php	(Revision 2199)
> +++ t3lib/class.t3lib_div.php	(Arbeitskopie)
> @@ -1646,7 +1646,7 @@
>  	 * @param	array		First array
>  	 * @param	array		Second array, overruling the first array
>  	 * @param	boolean		If set, keys that are NOT found in $arr0 (first array) will not be set. Thus only existing value can/will be overruled from second array.
> -	 * @param	boolean		If set, values from $arr1 will overrule if they are empty. Default: true
> +	 * @param	boolean		If set, values from $arr1 will overrule if they are empty or zero. Default: true
>  	 * @return	array		Resulting array where $arr1 values has overruled $arr0 values
>  	 */
>  	function array_merge_recursive_overrule($arr0,$arr1,$notAddKeys=0,$includeEmtpyValues=true) {
> @@ -1654,17 +1654,17 @@
>  		while(list($key,$val) = each($arr1)) {
>  			if(is_array($arr0[$key])) {
>  				if (is_array($arr1[$key]))	{
> -					$arr0[$key] = t3lib_div::array_merge_recursive_overrule($arr0[$key],$arr1[$key],$notAddKeys);
> +					$arr0[$key] = t3lib_div::array_merge_recursive_overrule($arr0[$key],$arr1[$key],$notAddKeys,$includeEmtpyValues);
>  				}
>  			} else {
>  				if ($notAddKeys) {
>  					if (isset($arr0[$key])) {
> -						if ($includeEmtpyValues OR $val) {
> +						if ($includeEmtpyValues || $val) {
>  							$arr0[$key] = $val;
>  						}
>  					}
>  				} else {
> -					if ($includeEmtpyValues OR $val) {
> +					if ($includeEmtpyValues || $val) {
>  						$arr0[$key] = $val;
>  					}
>  				}


More information about the TYPO3-team-core mailing list