            $layout[$position] = array($elem => $initLayout[$position][$elem]) + $layout[$position]; // unshift key-value pair
            $changed = true;
        }

        // remove obsolete widgets
        $arrayDiff =
                array_diff(array_keys($layoutWidgets), array_keys($initLayoutWidgets));
        foreach($arrayDiff as $elem){
            if(in_array ($elem, array_keys ($layout[$position]))) {
                unset($layout[$position][$elem]);
                $changed = true;
            } else if($position === 'right' && 
                in_array ($elem, array_keys ($layout['hiddenRight']))) {

                unset($layout['hiddenRight'][$elem]);
                $changed = true;
            }
        }

        // ensure that widget properties are the same as those in the default layout
        foreach($layout[$position] as $name=>$arr){
            if (in_array ($name, array_keys ($initLayoutWidgets)) &&
                $initLayoutWidgets[$name]['title'] !== $arr['title']) {

                $layout[$position][$name]['title'] = $initLayoutWidgets[$name]['title'];
                $changed = true;
            }
        }

        if ($position === 'right') {
            foreach($layout['hiddenRight'] as $name=>$arr){
                if (in_array ($name, array_keys ($initLayoutWidgets)) &&
                    $initLayoutWidgets[$name]['title'] !== $arr['title']) {

                    $layout['hiddenRight'][$name]['title'] = 
                        $initLayoutWidgets[$name]['title'];
                    $changed = true;
                }
            }
        }

        if($changed){
            $this->layout = json_encode($layout);
            $this->update(array('layout'));
        }
    }
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.