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

Crash when using "Revert" from advanced logs #99

Open
MegaphoneJon opened this issue Jun 22, 2023 · 1 comment
Open

Crash when using "Revert" from advanced logs #99

MegaphoneJon opened this issue Jun 22, 2023 · 1 comment

Comments

@MegaphoneJon
Copy link
Contributor

I know this complicates an already complicated set of NULLIF and IFNULL, but when you try to use the Revert this Change button on the advanced Change Log tab, you get a crash.

You have some code that generates this as part of a trigger:

 IFNULL(OLD.`amount_of_last_contribution_77`,'')

This places an empty string instead of a NULL, for understandable reasons.

However, these custom fields are of type "Money", and "Money" is validated with CRM_Utils_Rule::numeric(). That says only numeric values pass validation.

This normally doesn't come up because the triggers bypass validation, and the fields are read-only, so the value is never changed in a validated way - except if you try to revert the change.

I'm not sure it's worth the time it'll take to fix, but I wanted to make sure it's documented for others who experience this.

@jmcclelland
Copy link
Contributor

Thanks for the report @MegaphoneJon . I'm struggling to figure this one out - when grepping the code, I only see "IFNULL" in custom.php in the event attended and event no show queries - but not in the amount of last contribution query, so I'm not really share how that query is created. Or is that the query execute by CiviCRM core when reverting?

Maybe it's not worth fixing as you suggest, but since we define each field with their type, it seems at least theoretically possible to change a '' to a 0 for Money types?

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

No branches or pull requests

2 participants