Skip to content

updateForm accepts the raw accessEnum key #3424

@pringelmann

Description

@pringelmann

Describe the bug

updateForm in PATCH .../forms/{formId} applies updates with a dynamic setter loop in:

foreach ($keyValuePairs as $key => $value) {
    $method = 'set' . ucfirst($key);
    $form->$method($value);
}

That loop will call any matching setter on the Form entity. accessEnum is the raw integer column that access wraps, and it's only meant to be written through setAccess(), which normalises the boolean access payload and runs the config checks in checkAccessUpdate(). Passing accessEnum straight to the loop hits setAccessEnum() and skips all of that.

checkForbiddenKeys() already blocks the other internal columns, but its list doesn't include accessEnum:

$forbiddenKeys = [
    'id', 'hash', 'ownerId', 'created', 'lastUpdated', 'lockedBy', 'lockedUntil'
];

Expected behaviour

Clients should set form access through the access key only. accessEnum is an internal column and shouldn't be writable from the update payload.

Fix

Add accessEnum to the forbiddenKeys list in checkForbiddenKeys() so the loop rejects it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending approval or rejection. This issue is pending approval.bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions