-
-
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
improve performance when purifying tokens #32212
base: master
Are you sure you want to change the base?
improve performance when purifying tokens #32212
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
PS - anyone else who runs XDebug that can replicate my numbers, I'd appreciate it! I assume there's nothing that odd about my setup that would cause such different results on |
@MegaphoneJon oout of curiousity - is the apiv4 any different to v3? |
@@ -288,7 +295,7 @@ public function fill($format = NULL) { | |||
if ($entity == 'activity' && $field == 'details') { | |||
$htmlTokens[$entity][$field] = $value; | |||
} | |||
elseif (($entityFields['values'][$field]['data_type'] ?? NULL) === 'Memo') { | |||
elseif (($entityFields[$field]['data_type'] ?? NULL) === 'Text') { |
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'm confused about this. How the heck did it ever work before? Api3.getfields does not return "data_type". The output from the Api3 explorer looks like this:
"activity_details": {
"name": "details",
"type": 32,
"title": "Details",
"description": "Details about the activity (agenda, notes, etc).",
"rows": 8,
"cols": 60,
"usage": {
"import": true,
"export": true,
"duplicate_matching": true,
"token": false
},
"import": true,
"where": "civicrm_activity.details",
"export": true,
"table_name": "civicrm_activity",
"entity": "Activity",
"bao": "CRM_Activity_BAO_Activity",
"localizable": 0,
"html": {
"type": "RichTextEditor",
"rows": 8,
"cols": 60
},
"add": "1.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.
@colemanw @MegaphoneJon It seemed to get returned for custom fields tho
This is doing a civicrm_api3('contact', 'getfields', ['api_action' => 'get']); on smaster FYI
"custom_3": {
"id": "3",
"label": "Marriage Date",
"headerPattern": "//",
"title": "Marriage Date",
"custom_field_id": "3",
"groupTitle": "Constituent Information",
"data_type": "Date",
"name": "custom_3",
"type": 4,
"html_type": "Select Date",
"default_value": null,
"text_length": null,
"options_per_line": null,
"custom_group_id": "1",
"extends": "Individual",
"is_search_range": "0",
"extends_entity_column_value": null,
"extends_entity_column_id": "",
"is_view": "0",
"is_multiple": "0",
"option_group_id": null,
"date_format": "mm/dd/yy",
"time_format": 0,
"is_required": "0",
"table_name": "civicrm_value_constituent_information_1",
"column_name": "marriage_date_3",
"serialize": 0,
"where": "civicrm_value_constituent_information_1.marriage_date_3",
"extends_table": "civicrm_contact",
"search_table": "contact_a"
},
@eileenmcnaughton @seamuslee001 I address the v3/v4 and its custom fields in my original post. But now there are failing tests so hopefully I can address concerns that way. |
Now I'm wondering if this code does anything at all. If
|
looks like it started here #13283 |
Overview
We think of token rendering as expensive. But 90% of the time spent in
Civi\Token\TokenRow->render()
is spent on agetFields()
API call whose only purpose is to check if a field might have rich text so that we can purify it.We can replace this with a call to
\Civi\Api\Request->entityFields()
. In my testing, when combined with the caching in #32210, this reduces the time spent inCivi/Token/TokenRow::fill()
from 24 seconds to .28 seconds.Before
Slow.
After
Fast.
Comments
My main concern is that
getFields
returns custom fields in API3 and not in API4. However, in my testing, the custom fields are already populated in$htmlTokens
, so this has no effect.