Sorting/paging Advanced Search results corrupts search criteria
Overview
Certain search criteria fields in Advanced Search which have an implied LIKE operator are corrupted upon sorting by clicking on a column or by advancing to a different page in the results.
Two such fields are:
Contribution Source
Case Subject
Others fields, such as Contact Name, do not exhibit this problem.
Reproduction steps
- Login to https://dmaster.demo.civicrm.org
- Search | Advanced Search
- Display results as: Contributions
- Contribution | Contribution Source = "p"
- Click Search
- Note 59 results, displayed search criteria includes "Contribution Source Like %p%"
- Click the City column heading (or any other column heading), or display page 2 of the results.
Current behaviour
There are now 108 results, and the displayed search criteria includes "Contribution Source Like %%"
Expected behaviour
The search criteria should not be affected by sorting or paging the results.
Environment information
- Browser: Chrome/102.0.5005.63
- CiviCRM: 5.50.0
- PHP: 7.4.29
- CMS: Drupal 7.88
- Database: MariaDB 10.4.13
- Web Server: Apache 2.4.43
Comments
Problem traced to /CRM/Core/Form/Search.php:convertTextStringsToUseLikeOperator() calling trim() on $this->_formValues[$fieldName]. That variable, in the affected cases, is an array rather than a string, e.g. ['LIKE' => 'search_value'].