1

I have an error when working with Accounting Batches. It's kind of hard to pin down - the front end gives the default / standard / very helpful. What I did was:

  • add a new accounting Batch (Contributions > Accounting Batches > New Batch)
  • Assign a contribution to the batch
  • try to remove the contribution from the batch

at this point I get:

No response from the server. Check your internet connection and try reloading the page.

message, but ConfigAndLog does give a bit more, i.e.:

$Fatal Error Details = array:3 [
  "message" => "Cannot delete EntityBatch with no id."
  "code" => null
  "exception" => CRM_Core_Exception {#2039
    -errorData: array:1 [
      "error_code" => 0
    ]
    #cause: null
    -_trace: null
    #message: "Cannot delete EntityBatch with no id."
    #code: 0
    #file: "/var/www/html/drupal7/sites/all/modules/civicrm/CRM/Core/DAO.php"
    #line: 958
    trace: {
      /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Core/DAO.php:958 {
        › if (empty($record['id'])) {
        ›   throw new CRM_Core_Exception("Cannot delete {$entityName} with no id.");
        › }
      }
      /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Batch/BAO/EntityBatch.php:39 { …}
      /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Financial/Page/AJAX.php:207 { …}
      /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Utils/REST.php:266 { …}
      /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Utils/REST.php:550 { …}
      /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Core/Invoke.php:279 { …}
      /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Core/Invoke.php:69 { …}
      /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Core/Invoke.php:36 { …}
      /var/www/html/drupal7/sites/all/modules/civicrm/drupal/civicrm.module:458 { …}
      /var/www/html/drupal7/includes/menu.inc:527 { …}
      /var/www/html/drupal7/index.php:21 { …}
    }
  }
]


Jan 21 15:24:29  [debug] $backTrace = #0 /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Core/Error.php(433): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /var/www/html/drupal7/sites/all/modules/civicrm/CRM/Core/Invoke.php(39): CRM_Core_Error::handleUnhandledException(Object(CRM_Core_Exception))
#2 /var/www/html/drupal7/sites/all/modules/civicrm/drupal/civicrm.module(458): CRM_Core_Invoke::invoke((Array:3))
#3 /var/www/html/drupal7/includes/menu.inc(527): civicrm_invoke("ajax", "rest")
#4 /var/www/html/drupal7/index.php(21): menu_execute_active_handler()
#5 {main}

I'm at a bit of a loss where to go with this - could anyone give any pointers?

I've just realised that this is also happening on a local buildkit drupal-clean. is this a bug?

This is on CiviCRM 5.41.1

Thanks in Advance

7
  • What were you trying to do to cause the error? Jan 25, 2022 at 15:34
  • Just added to the batch, and then tried to 'remove' the added item.
    – Marsh
    Jan 25, 2022 at 16:11
  • ...have updated the Question - sorry - didn't realise I'd not mentioned what I'd done. not ver useful!
    – Marsh
    Jan 25, 2022 at 16:18
  • I've also tried this locally on a fresh drupal9-clean install - I get the same issue just by starting a batch, adding a contribution, and attempting to remove the batch @PradeepNayak
    – Marsh
    Jan 31, 2022 at 11:36
  • could you try on dmaster? Jan 31, 2022 at 13:37

1 Answer 1

2

Looks like a regression from commit#99f7626

Could you try below patch?

diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php
index ac2a002c4c..a314f5e736 100644
--- a/CRM/Financial/Page/AJAX.php
+++ b/CRM/Financial/Page/AJAX.php
@@ -170,13 +170,24 @@ class CRM_Financial_Page_AJAX {
         switch ($op) {
           case 'assign':
           case 'remove':
-            if ($op == 'remove' || $op == 'assign') {
-              $params = [
-                'entity_id' => $recordID,
-                'entity_table' => 'civicrm_financial_trxn',
-                'batch_id' => $entityID,
-              ];
+            $params = [
+              'entity_id' => $recordID,
+              'entity_table' => 'civicrm_financial_trxn',
+              'batch_id' => $entityID,
+            ];
+
+            if ($op == 'remove') {
+              try {
+                $id = civicrm_api3('EntityBatch', 'getvalue', $params + [
+                  'return' => 'id',
+                ]);
+                $params = ['id' => $id];
+              }
+              catch (Exception $e) {
+                $errorMessage = $e->getMessage();
+              }
             }
+
             break;
 
           case 'close':
@@ -214,9 +225,9 @@ class CRM_Financial_Page_AJAX {
               'status_id' => $redirectStatus,
             ];
           }
-          if ($errorMessage ?? FALSE) {
-            $response = ['status' => $errorMessage];
-          }
+        }
+        if ($errorMessage ?? FALSE) {
+          $response = ['status' => $errorMessage];
         }
       }
     }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.