Closed picocodes closed 1 year ago
Can you specify the page too where this function is being executed or maybe list out steps to recreate this issue?
Hi @sachyya, install the Query Monitor plugin then open the frontend users page.
A quick fix would be:-
$cache_key = $htmlvar_name . '_' . $form_type;
if ( isset( $GLOBALS['uwp_custom_field_info'][ $cache_key ] ) ) {
return $GLOBALS['uwp_custom_field_info'][ $cache_key ];
}
The multiple calls being made is due to the filter uwp_get_usermeta
applied in class-meta.php L105 in which modify_datepicker_value_on_get
is being hooked. That hooked function executes uwp_get_custom_field_info
.
In default setting, modify_datepicker_value_on_get
does nothing to modify to the filter. I suppose it can be omitted. Can you specify the use case of this function? Otherwise, I suppose a simple one would be to omit this filter that in return reduces the function calls.
The function retrieves a field's settings as defined in the UWP form builder. I'm not sure that removing the filter is the correct fix since the function is called in several other places.
Please check how the same issue was fixed in GeoDirectory.
https://github.com/AyeCode/geodirectory/issues/2104 https://github.com/AyeCode/geodirectory/blob/master/includes/custom-fields/functions.php#L364
Checked and this function executes the same db query 196 times in a single page load ( on a page with lots of users ). We can cache the results using a static or global variable to ensure that it only reads the db once.