Skip to content

[redcap] Fix record field name implicit int conversion #9915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MaximeBICMTL
Copy link
Contributor

@MaximeBICMTL MaximeBICMTL commented Jul 18, 2025

Description

I have an instrument with some integer-like field names in REDCap ("0" / "1"), this caused a type error in RedcapNotificationHandler with "string expected, int given". After investigating a bit, REDCap correctly sends the field namesas strings but it turns out that PHP implicitly converts array keys to integers if they look like integers.

Changelog

  • Add a strval in the regex matching where the field name is required to be a string.
  • Make _formatEnumFields slightly less unreadable by using a foreach instead of array_keys / array_reduce.

@MaximeBICMTL MaximeBICMTL requested a review from regisoc July 18, 2025 13:52
@MaximeBICMTL MaximeBICMTL added Category: Bug PR or issue that aims to report or fix a bug Priority: High PR or issue should be prioritised over others for review and testing Language: PHP PR or issue that update PHP code Module: redcap PR or issue related to redcap module Project: C-BIG Issue or PR related to the C-BIG project labels Jul 18, 2025
@MaximeBICMTL MaximeBICMTL changed the title [redcap] Fix record field name implicit int conversion. [redcap] Fix record field name implicit int conversion Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Bug PR or issue that aims to report or fix a bug Language: PHP PR or issue that update PHP code Module: redcap PR or issue related to redcap module Priority: High PR or issue should be prioritised over others for review and testing Project: C-BIG Issue or PR related to the C-BIG project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant