Important: The select item helper passes an empty row
Description
\FGTCLB\ declared the
parameter
row
as always present. In the backend form it is, because
TYPO3 hands the record being edited to every
items.
Get
calls the
items of a field outside the backend form, and the
job form of
fgtclb/academic-jobs
builds the options of its fields
Job Type and Employment Type with it. There is no
record there, and the helper passed no
row
at all. A listener of the
event that read
$parameters without a fallback raised the
warning Undefined array key "row" in the job form, and the job form failed
where warnings are turned into exceptions, as with the debug preset.
Two changes resolve that:
- The helper passes
rowas an empty array. - The event, and the item providers
TypeandItems Employmentof fgtclb/academic-jobs , declareType Items rowoptional in their parameter shape,row?:, so static analysis reports a listener that reads it without a fallback.
Impact
A listener that reads
$parameters itself gets an empty array in
the job form now instead of a warning. A listener that reads a field of the
row, such as
$parameters, still raises a warning there,
Undefined array key "pid", because the empty row has no fields. Read the
row and every field of it with a fallback:
$row = $parameters['row'] ?? [];
$pageId = (int)($row['pid'] ?? $parameters['effectivePid']);
The backend form passes the record as before. Nothing changes for a listener
that reads the row with a fallback already, unless it tells the job form apart
by a missing row, with
isset,
array_ or
($parameters. Such a check takes the backend
branch in the job form now. Check for an empty row instead:
$isJobForm = ($parameters['row'] ?? []) === [];
A project that runs static analysis over its listeners may see a new report
about the offset
'row'
where a listener reads the row without a
fallback. That report points at the code that failed in the job form.
Affected Installations
Installations with a listener of
\FGTCLB\ that reads
$parameters, and that use the job form of
fgtclb/academic-jobs
or call the helper in an own controller.