Project

General

Profile

Bug #79426

Updated by Thomas Hohn over 7 years ago

The following code will crash with an runtime-error if $dataStructureArray['sheets'] is not an array 
 @ 
 // @// Traverse languages: 
 
         foreach ($dataStructureArray['sheets'] as $sheetKey => $sheetData) { 
     
             // Render sheet: 
     
             if (is_array($sheetData['ROOT']) && is_array($sheetData['ROOT']['el'])) { 
         
                 $PA['vKeys'] = ['DEF']; 
         
                 $PA['lKey'] = 'lDEF'; 
         
                 $PA['callBackMethod_value'] = $callBackMethod_value; 
         
                 $PA['table'] = $table; 
         
                 $PA['field'] = $field; 
         
                 $PA['uid'] = $row['uid']; 
         
                 // Render flexform: 
     
                 $this->traverseFlexFormXMLData_recurse($sheetData['ROOT']['el'], $editData['data'][$sheetKey]['lDEF'], $PA, 'data/' . $sheetKey . '/lDEF'); 
     
             } else { 
         
                 return 'Data Structure ERROR: No ROOT element found for sheet "' . $sheetKey . '".'; 
     
             } 
 } 
 @ 
         }@ 

 It would ne nicer to add a check if $dataStructureArray is not an array and then return an error string 
 @ 
 // @// Check if $dataStructureArray['sheets'] is indeed an array before loop or it will crash with runtime error 
 
         if (!is_array($dataStructureArray['sheets'])) { 
     
             return 'Data Structure ERROR: sheets is defined but not an array for table ' . $table . (isset($row['uid']) ? ' and uid ' . $row['uid'] : ''); 
 } 
 @ 
         }@

Back