Issue Bug Closed

#98630PHP Warning: Undefined array key foobar in typo3_src-11.5.17/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php line 1394

Ralph Brugger 10/17/22, 07:57 updated 02/08/23, 16:07

Description

PHP Warning: Undefined array key foobar in typo3_src-11.5.17/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php line 1394

    public function pi_getFFvalue($T3FlexForm_array, $fieldName, $sheet = 'sDEF', $lang = 'lDEF', $value = 'vDEF')
    {
        $sheetArray = is_array($T3FlexForm_array) ? $T3FlexForm_array['data'][$sheet][$lang] : '';

The warning occures when the stored flexform data doesn’t contain a flexform sheet ($sheet) that has been added to a flexform but the record is outdated.

Solution could be?

public function pi_getFFvalue($T3FlexForm_array, $fieldName, $sheet = 'sDEF', $lang = 'lDEF', $value = 'vDEF')
{

    if (isset($T3FlexForm_array['data'][$sheet])){

      $sheetArray = is_array($T3FlexForm_array) ? $T3FlexForm_array['data'][$sheet][$lang] : '';
      if (is_array($sheetArray)) {
          return $this->pi_getFFvalueFromSheetArray($sheetArray, explode('/', $fieldName), $value);
      }
    }
    return null;
}

Reviews 2