-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
[WIP] APIv4: allow a field named "is_active" to default to false #27764
[WIP] APIv4: allow a field named "is_active" to default to false #27764
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
37f3d91
to
9db25df
Compare
if ($DAOField['name'] == 'is_active' && (!isset($DAOField['default']) || $DAOField['default'] === '')) { | ||
$DAOField['default'] = '1'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, I forgot this code existed. I think we should just delete it. Our schema used to be very inconsistent but there's been a lot of work lately to clean up boolean columns and ensure they always have the correct default set at the sql level so I think we can rely on that now and get rid of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. What about the test?
It seems a bit redundant after deletion, but more test is usually better than less 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes keep it. Always good to have a test!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. I've squashed the commits for nicer history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. Let's see what the test suite thinks of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like test suite doesn't like it...
I believe the reason is a missing <default>1</default>
on civicrm_acl.is_active
.
I've added a quick hack to simulate that and to verify tests pass with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick hack didn't work so I did the proper way 😄
Missing default on civicrm_acl.is_active
is just part of the reasons... Though there are 2 less failing test cases.
Seems, we need to go through the rest of the failing tests.
I think it's better to divide this PR into smaller parts and extract missing default on civicrm_acl.is_active
as it's independent of this and needs to fixed anyway.
9db25df
to
a31567b
Compare
Overview
If an entity has a field named "is_active" and it's default is defined as
0
in the schema, APIv4 overrides it to1
.This effectively prevents these entities to be created as not active by default (when "is_active" is omitted from parameters).
Before
(Output trimmed for brevity)
After
(Output trimmed for brevity)
Technical Details
Similar to #27302
Comments
I ran into this in an extension, so it's possible to rename the field to "is_enabled" or something like that to workaround this limitation.
But there is one example in core: Dashboard entity, where APIv4 don't follow specifications, so this should be fixed.