In a contribution search if the date filter is set to be mandatory by the user, the export action(s) are breaking with a MySQL error
Scenario
- A contribution search with the Contribution date filter set as "required by the user"
- An exposed search form with the option "Expand criteria form initially" checked
- Run the search and put a date (I've used the from-to date for around 1000 contributions)
- Select all records (important!)
- From the actions bar, select "Export contributions"
Or simply import this json file: testcontributionsearch.json
You should be getting this:
SQL error & stack trace
Exception: "invalid criteria for IN"
#0 /platform/vendor/civicrm/civicrm-core/CRM/Contact/BAO/Query.php(5668): CRM_Core_DAO::createSQLFilter()
#1 /platform/vendor/civicrm/civicrm-core/CRM/Contribute/BAO/Query.php(243): CRM_Contact_BAO_Query::buildClause()
#2 /platform/vendor/civicrm/civicrm-core/CRM/Contribute/BAO/Query.php(113): CRM_Contribute_BAO_Query::whereClauseSingle()
#3 /platform/vendor/civicrm/civicrm-core/CRM/Core/Component.php(239): CRM_Contribute_BAO_Query::where()
#4 /platform/vendor/civicrm/civicrm-core/CRM/Contact/BAO/Query.php(2081): CRM_Core_Component::alterQuery()
#5 /platform/vendor/civicrm/civicrm-core/CRM/Contact/BAO/Query.php(575): CRM_Contact_BAO_Query->whereClause()
#6 /platform/vendor/civicrm/civicrm-core/CRM/Contact/BAO/Query.php(524): CRM_Contact_BAO_Query->initialize()
#7 /platform/vendor/civicrm/civicrm-core/CRM/Contribute/Form/Task/TaskTrait.php(49): CRM_Contact_BAO_Query->__construct()
#8 /platform/vendor/civicrm/civicrm-core/CRM/Contribute/Form/Task/TaskTrait.php(124): CRM_Contribute_Export_Form_Select->getSearchQueryResults()
#9 /platform/vendor/civicrm/civicrm-core/CRM/Contribute/Form/Task/TaskTrait.php(107): CRM_Contribute_Export_Form_Select->calculateIDS()
#10 /platform/vendor/civicrm/civicrm-core/CRM/Contribute/Form/Task.php(52): CRM_Contribute_Export_Form_Select->getIDs()
#11 /platform/vendor/civicrm/civicrm-core/CRM/Contribute/Export/Form/Select.php(31): CRM_Contribute_Form_Task::preProcessCommon()
#12 /platform/vendor/civicrm/civicrm-core/CRM/Export/Form/Select.php(104): CRM_Contribute_Export_Form_Select->callPreProcessing()
#13 /platform/vendor/civicrm/civicrm-core/CRM/Core/Form.php(707): CRM_Export_Form_Select->preProcess()
#14 /platform/vendor/civicrm/civicrm-core/CRM/Core/QuickForm/Action/Display.php(76): CRM_Core_Form->buildForm()
#15 /platform/vendor/civicrm/civicrm-packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display->perform()
#16 /platform/vendor/civicrm/civicrm-packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle()
#17 /platform/vendor/civicrm/civicrm-core/CRM/Core/Controller.php(355): HTML_QuickForm_Page->handle()
#18 /platform/web/sites/mysite/files/civicrm/ext/dataprocessor/CRM/DataprocessorSearch/Controller/Search.php(112): CRM_Core_Controller->run()
#19 /platform/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(319): CRM_DataprocessorSearch_Controller_Search->run()
#20 /platform/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem()
#21 /platform/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke()
#22 /platform/web/modules/contrib/civicrm/src/Civicrm.php(88): CRM_Core_Invoke::invoke()
#23 /platform/web/modules/contrib/civicrm/src/Controller/CivicrmController.php(83): Drupal\civicrm\Civicrm->invoke()
#24 [internal function](): Drupal\civicrm\Controller\CivicrmController->main()
Rework
If you either:
- Remove the checkbox "required by the user" or ..
- Select only the first 50 entries
The export action works just fine
Further digging
I've only managed to find that in our problematic case, the contribution IDs are not being sent to the form/action. CRM_Contribute_Export_Form_Select->getIDs()
is empty and it crashes there.