-
-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Environment
- Craft CMS: 5.9.8
- PHP: 8.2
- Plugin: verbb/tablemaker 5.0.6
Description
When querying a Table Maker field via GraphQL that includes the rows sub-field, the server returns an internal error:
Undefined array key "type"
Column headings render correctly, but row data fails to resolve.
Steps to reproduce
- Install Craft CMS 5.x with
verbb/tablemaker5.0.6 - Create a Table Maker field with standard text columns (no Date or Time column types)
- Add data to the table in the control panel
- Query the field via GraphQL:
... on table_Entry {
typeHandle
table {
columns {
align
heading
width
}
rows
}
caption
}- The query returns an internal server error instead of row data
Root cause
In vendor/verbb/tablemaker/src/fields/TableMakerField.php at line 277, the rows resolver iterates over columns and accesses $column['type'] without checking if the key exists:
// Line 275-283
foreach ($source['rows'] as $rowKey => $row) {
foreach ($source['columns'] as $columnKey => $column) {
if ($column['type'] === 'date' || $column['type'] === 'time') {
$value = $row[$columnKey] ?? null;
$source['rows'][$rowKey][$columnKey] = DateTimeHelper::toIso8601($value);
}
}
}Columns that are plain text (or were created before the type property was introduced) do not have a type key in their data. On PHP 8.0+, accessing an undefined array key triggers a warning/error, which causes the GraphQL query to fail.
Craft CMS version
5.9.8
Plugin version
5.0.6
Multi-site?
No
Additional context
Suggested fix
Add an isset() guard before accessing $column['type']:
foreach ($source['rows'] as $rowKey => $row) {
foreach ($source['columns'] as $columnKey => $column) {
if (isset($column['type']) && ($column['type'] === 'date' || $column['type'] === 'time')) {
$value = $row[$columnKey] ?? null;
$source['rows'][$rowKey][$columnKey] = DateTimeHelper::toIso8601($value);
}
}
}I've tested manually patching the vendor folder file with the fix above and that appears to resolve the issue.