diff --git a/php/libraries/CSVParser.class.inc b/php/libraries/CSVParser.class.inc index 3ff04c382c7..53b97144886 100644 --- a/php/libraries/CSVParser.class.inc +++ b/php/libraries/CSVParser.class.inc @@ -37,17 +37,18 @@ class CSVParser /** * Check that headers match (equivalent arrays) * - * @param array $headers Headers parsed from csv file - * @param array $expectedHeaders Expected headers (ex: from instrument) - * @param bool $strict If true, $headers cannot be a superset - * of $expectedHeaders + * @param array|false $headers Headers parsed from csv file + * @param array $expectedHeaders Expected headers (ex: from instrument) + * @param bool $strict If true, $headers cannot be a superset + * of $expectedHeaders * - * @return bool Returns true if headers are valid + * @return bool Returns true if headers are valid */ private function _validateHeaders( - array $headers, array $expectedHeaders, bool $strict = false + array|false $headers, array $expectedHeaders, bool $strict = false ): bool { - if ($strict && count($headers) !== count($expectedHeaders)) { + if (!$headers || ($strict && count($headers) !== count($expectedHeaders)) + ) { return false; } diff --git a/php/libraries/InstrumentDataParser.class.inc b/php/libraries/InstrumentDataParser.class.inc index 13c4f37768a..a36a261e607 100644 --- a/php/libraries/InstrumentDataParser.class.inc +++ b/php/libraries/InstrumentDataParser.class.inc @@ -75,10 +75,7 @@ class InstrumentDataParser extends CSVParser ): array { return array_merge( ['PSCID', 'Visit_label'], // SessionID - // Convert to static list of flag fields - // List: Data_entry, Required_elements_completed, Administration, - // Validity, Exclusion, Testdate - self::getFlagHeaders( // Whitelist would prevent invalid columns + self::getFlagHeaders( [ 'ID', 'SessionID', 'Test_name', 'TestID', 'CommentID', 'UserID', 'Data', 'DataID',