Skip to content
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

Fix: Ensure duplicateAndHydrate works with Fields using static closures #535

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

fritz-c
Copy link
Contributor

@fritz-c fritz-c commented Feb 7, 2025

Nova's DateTime field (at least the one in Nova v5) uses a static anonymous function to define how to resolve the data to a string. This causes problems in the cloneField (and the dependent duplicateAndHydrate) method in your code, which binds a few of the field callbacks back to the newly cloned field instance. The specific error is:

Cannot bind an instance to a static closure

I initially implemented a fix using ReflectionFunction to detect if a function is static, but settled for a try-catch just in case reflection causes some sort of performance issue at low numbers.

@eslamabdallah74
Copy link

Nice job, this worked with me

@fritz-c
Copy link
Contributor Author

fritz-c commented Feb 11, 2025

@voidgraphics Sorry to bother you, but if you have some time, I'd appreciate if you could look this over. It's essentially a three-line code change (adding a try-catch for an otherwise unavoidable error), accompanied by a thorough new test case where nothing existed before.

@voidgraphics voidgraphics merged commit d48d607 into whitecube:master Feb 11, 2025
@voidgraphics
Copy link
Member

Thanks for the fix @fritz-c!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants