-
-
Notifications
You must be signed in to change notification settings - Fork 853
Cache option values in BasicGetFieldsAction #34227
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
Conversation
|
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
| * @param string $optionGroupName | ||
| * @deprecated | ||
| */ | ||
| public function pseudoconstantOptions(string $optionGroupName) { |
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.
This seemed a poorly named function given it only deals with one type of pseudoconstant.
It's also strange as a public instance method on an Api action class.
I didn't see any other callers in core and think it could probably be ripped out, but kept as deprecated for the time being.
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.
@ufundo let's just say mistakes were made when this function was added. Rip out sounds good to me.
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.
It's not called from anywhere in universe. Let's delete it.
|
@colemanw @eileenmcnaughton I think this could be a good answer to https://lab.civicrm.org/dev/core/-/issues/6229#note_195346 |
|
An alternative to this could be to add the caching into |
Ahh, well, I was working on that at one point... If we got that PR over the line, this might become moot. |
|
Ah, that PR looks interesting. It's always seemed a bit odd to me BasisEntity fields were defined in the getfields action itself. Then again, maybe it's a bit weird to have a Either way I don't think it makes the whole thing moot, because there other BasicEntities outside of core. |
1 similar comment
|
Ah, that PR looks interesting. It's always seemed a bit odd to me BasisEntity fields were defined in the getfields action itself. Then again, maybe it's a bit weird to have a Either way I don't think it makes the whole thing moot, because there other BasicEntities outside of core. |
|
It would definitely be nice for BasicEntities to go through I don't know my way round all of the EntityRepository stuff, but is the PR using I think it could be nice to store the metadata for tableless entities somewhere else also - maybe directly on the \Civi\Api4[Entity] class, as |
|
Do you have any reservations with this version for now @colemanw ? |
4bc14b0 to
7824a12
Compare
Ensures option lists are cached for non-DAO entities like Afform Fixes dev/core#6229
7824a12 to
bfa8fae
Compare
Overview
Avoid fetching OptionValues for every row in BasicGetFieldsAction. Improves the performance of getting BasicEntities, with the most notable core example being Afform.
Before
pseudoconstant.optionGroupNameare fetched for every row in order to format pseudoconstantsAfter
Technical Details
Here's a test script:
3 runs on master:
3 runs on this branch:
So its pretty slight but 5% improvement, on a basic site with 70 afforms. I would expect a lot of sites have more forms, and repeated calls over multiple requests = more savings.
I also have a follow up which adds caching to callbacks, which has more significant performance boost.
Previous caching for pseudoconstant field options seems to only apply to schema/table based fields - this is the exceptional case because it's on tableless entity.
It is a bit odd to me that we dont have a global cache for option values, as far as I can see. There's another
CRM_Core_optionValue::getValues(['name' => $name])type call in SettingsMetadata which might benefit from using the same cache.