-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
dev/core#2743 fix api v3 to not unnecessarily load options #21099
Conversation
(Standard links)
|
9686d46
to
7d6056f
Compare
7d6056f
to
2899f87
Compare
(!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options']) || $fieldName === 'campaign_id') | ||
// if it is already numeric AND it is an FK field we don't need to validate because | ||
// sql will do that for us on insert (this also saves a big lookup) | ||
&& (!is_numeric($fieldValue) || empty($fieldInfo['FKClassName'])) |
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.
I have re-written this line 8 times so I'm gonna write out what I'm doing
We will validate if it's a a pseudoconstant, has options or is campaign id
AND it is not an FK OR the value is not numeric
Ie if it is an FK & we have a string then validate
if it's numeric & it's controlled by option values then validate
but don't validate a numeric FK field
This looks good code-wise and makes a lot of sense. It's also heavily covered by tests. |
@colemanw this caused 3 test failures - in all 3 cases they were upset about the subtle difference in the error message. I kept one test but removed the error message check & I actually removed the other 2. In general I think we have an overkill of these tests that check failure messages so keeping 1 was enough IMHO |
Overview
dev/core#2743 fix api v3 to not unnecessarily load options
Before
Campaign options loaded for verification even when its already an int
After
Only loaded if needed
Technical Details
We don't need to validate if already numeric
Comments
@colemanw this is actually very similar to @pfigel's hack & I think it makes sense for the rc