agileware / wp-civicrm-ux

WordPress CiviCRM UX - User Experience enhancements
GNU General Public License v2.0
7 stars 12 forks source link

Improving integer parsing for url parameters #17

Closed wcha-peter closed 2 years ago

wcha-peter commented 2 years ago

Sometimes, the id parameter is passed into the [ux_cv_api4_get] as a string, and in this case the is_int check fails, making it impossible to retrieve a specific result.

The new check uses the FILTER_VALIDATE_INT filter, which will correctly categorize integer strings, but can falsely validate some decimal strings as integers.

This one is probably an improvement, as it covers all of the common cases (providing an integer or providing a word), but there might be a more consistent way of validating integers and integer strings.

agileware-fj commented 2 years ago

Couldn't merge this PR since it also introduces an inefficient change to caching - but I've applied your fix. Thank you.