CiviCRM core exception when trying to import contributions
Overview
We are getting a core exception when trying to import contributions on a client site via Contribution Import.
We've have seen the same behaviour in another client site that is using the CSV import extension.
Reproduction steps
- Go to Import Contributions
- Complete first three steps of import process up to the point where you preview the contributions to import
- Click Import Now
Current behaviour
Sometimes the import works, sometimes it doesn't. This depends on the job number that CiviCRM chooses for the import.
If there isn't a row in the civicrm_queue
table with a matching job number (or if you delete the matching row before import) then the import is successful.
If there is a row in the civicrm_queue
table with a matching job number then the import fails and you get the error below:
CRM_Core_Exception: Cannot execute queue "user_job_8". The "civicrm_queue.runner" property is missing. in /var/www/html/sites/all/modules/civicrm/CRM/Queue/Runner.php on line 163
Exception trace
# Function Location
0 CRM_Queue_Runner->assertRequirementsBackground() /var/www/html/sites/all/modules/civicrm/CRM/Queue/Runner.php:163
1 CRM_Queue_Runner->runAllInteractive() /var/www/html/sites/all/modules/civicrm/CRM/Import/Form/Preview.php:120
2 CRM_Import_Form_Preview->runTheImport() /var/www/html/sites/all/modules/civicrm/CRM/Import/Form/Preview.php:100
3 CRM_Import_Form_Preview->postProcess() /var/www/html/sites/all/modules/civicrm/CRM/Core/Form.php:612
4 CRM_Core_Form->mainProcess() /var/www/html/sites/all/modules/civicrm/CRM/Core/StateMachine.php:144
5 CRM_Core_StateMachine->perform() /var/www/html/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php:43
6 CRM_Core_QuickForm_Action_Next->perform() /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php:203
7 HTML_QuickForm_Controller->handle() /var/www/html/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php:103
8 HTML_QuickForm_Page->handle() /var/www/html/sites/all/modules/civicrm/CRM/Core/Controller.php:355
9 CRM_Core_Controller->run() /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:319
10 CRM_Core_Invoke::runItem() /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:69
11 CRM_Core_Invoke::_invoke() /var/www/html/sites/all/modules/civicrm/CRM/Core/Invoke.php:36
12 CRM_Core_Invoke::invoke() /var/www/html/sites/all/modules/civicrm/drupal/civicrm.module:471
13 civicrm_invoke() /var/www/html/includes/menu.inc:527
14 menu_execute_active_handler() /var/www/html/index.php:21
15 {main}
Expected behaviour
The import should be successful every time.
Environment information
- CiviCRM: 5.62.1
- PHP: 8.1.22 (also tried on PHP 7.4 and 8.0)
- CMS: Drupal 7.98
- Database: MySQL 5.7.43
- Web Server: Apache 2.4.56
Comments
See also this post on StackExchange for the same/similar issue: https://civicrm.stackexchange.com/questions/45073/why-would-the-civicrm-queue-runner-property-be-missing
Workaround
RUN THIS QUERY AT YOUR OWN RISK. Please test first.
First flush the CiviCRM cache (e.g. cv flush
) to remove any expired items form the civicrm_user_job
table.
Then run the following query to delete the rows in civicrm_queue
that don't have matching rows in civicrm_user_job
:
DELETE q FROM civicrm_queue q
LEFT JOIN civicrm_user_job uj ON q.name = CONCAT('user_job_', uj.id)
WHERE uj.id IS NULL;