Answers.Body: <p>I got a similar DataTables warning recently that prevented me from viewing exported batches. I was also able to change the batch status and see them in the 'closed' list.  [running CiviCRM 5.13.5 and php 7.2 on WordPress]</p>
  
  <p>The problem turned out to be that I had recently deleted activities, including the export batch activities.  Apparently, if so much as one export batch activity has been deleted, the list of exported batches will fail with a DataTables warning.  </p>
  
  <p>I was able to fix the problem by manually changing the status of all exported batches to closed, then re-exporting them, thereby recreating activity records for the exported batches (fortunately, only 12 large batches of imported donations as we are still in the setup phase). I deleting the activity record for just one exported batch to verify that the problem is caused by one or more missing activity records for exported batches.</p>
  
  <p>This seems like a bug, since an activity record probably shouldn't be required to view the exported batch list (other type of activity can be safely deleted). I think the export activity record is somehow being used to link to the exported files in the [civicrm.files]/custom/ directory (though the exported files themselves can apparently be deleted without trouble if no longer needed).</p>
  
  <p>The actual functionality of the batches did not seem to be impaired (new batches and exports worked and I could search contributions on batch criteria).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-23T19:35:33.133Z
Answers.Text: Do you know how to apply patches?  If so, could you please apply this patch and report back if it fixes your problem? https://github.com/civicrm/civicrm-core/pull/14367
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-23T19:39:02.020Z
Answers.Text: OK, I just replicated your problem and can confirm that this patch fixes it.  If you know how, you can apply it now to solve your problem immediately.  If not, I'll link this conversation to the patch in the hopes that it will aid the case for getting it included in CiviCRM.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-25T01:05:01.790Z
Answers.Text: Thanks Jon.  I haven't learned how to apply a patch yet, but since you confirmed that it fixes my issue, I just won't delete batch activities for the time being...
Answers.UserDisplayName: Don Alejandro
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-26T13:15:14.087Z
Answers.Text: It just got merged into Civi 5.18, which comes out the first weekend in October.  You can upgrade then!
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-23T18:34:53.713Z
Answers.LastActivityDate: 2019-08-23T18:34:53.713Z
Answers.UserDisplayName: Don Alejandro
Answers.Body: <p>Okay, solved. There was something awry with the latest Batch in that it had been exported, but the file didn't exist in the <code>custom</code> directory/filesystem. I changed that last batch status directly in the database from <code>5</code> (exported) to <code>2</code> (closed) and now the screens all load as usual.</p>
  
  <p>I suppose line 335 of <code>/path-to-site/sites/all/modules/civicrm/CRM/Batch/BAO/Batch.php</code> is trying to load information about this non-existent file and causes the error somehow, but I don't fully understand how.</p>
  
  <p><strong>EDIT</strong>: The error recurred when we tried to re-export the problem batch, but I was able to get a more helpful error message this time:</p>
  
  <blockquote>
    <p>Error: [] operator not supported for strings in CRM_Financial_BAO_ExportFormat_CSV->formatHeaders() (line 166 of /path-to-site/sites/all/modules/civicrm/CRM/Financial/BAO/ExportFormat/CSV.php).</p>
  </blockquote>
  
  <p>So this is in fact a PHP 7.1 bug. <a href="https://lab.civicrm.org/dev/core/issues/452" rel="nofollow noreferrer">Issue in lab is here</a>. <a href="https://github.com/civicrm/civicrm-core/pull/12946" rel="nofollow noreferrer">PR is here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-18T06:11:06.967Z
Answers.Text: Above patch is merged & will be in the 5.8 release
Answers.UserDisplayName: user4278
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-16T18:38:51.423Z
Answers.LastActivityDate: 2018-10-17T15:38:10.293Z
Answers.LastEditDate: 2018-10-17T15:38:10.293Z
Answers.UserDisplayName: Laryn
Body: <p>I just had a report that someone is having trouble seeing the list of exported batches (<strong>civicrm/financial/financialbatches?reset=1&amp;batchStatus=5</strong>) and it seems to have started just recently -- likely after I upgraded to CiviCRM 5.6 (I also recently upgraded from PHP 7.0 to PHP 7.1 but I reverted that as a test and still had the error). The strange part is that there is no error in viewing the list of Open or Closed batches, just the Exported batches. There are a lot of exported batches -- could the volume of batches be an issue here?</p>
  
  <p>The only error I've been able to track down is the popup error:</p>
  
  <blockquote>
    <p>DataTables warning: table id=crm-batch-selector-5 - Ajax error. For more information about this error, please see <a href="http://datatables.net/tn/7" rel="nofollow noreferrer">http://datatables.net/tn/7</a></p>
  </blockquote>
  
  <p>...and the one in the Drupal watchdog log:</p>
  
  <blockquote>
    <p>Notice: Trying to get property of non-object in CRM_Batch_BAO_Batch::getBatchList() (line 335 of /path-to-site/sites/all/modules/civicrm/CRM/Batch/BAO/Batch.php).</p>
  </blockquote>
  
  <hr>
  
  <ul>
  <li>Drupal 7</li>
  <li>CiviCRM 5.6.0</li>
  <li>PHP 7.1</li>
  </ul>
  
Tags: <batches>
Title: Can't view Exported Batches (DataTables warning)
ThreadText: # Can't view Exported Batches (DataTables warning)
  
  (Asked by: username_0 on 2018-10-12)
  
  I just had a report that someone is having trouble seeing the list of exported batches (**civicrm/financial/financialbatches?reset=1&batchStatus=5**) and it seems to have started just recently -- likely after I upgraded to CiviCRM 5.6 (I also recently upgraded from PHP 7.0 to PHP 7.1 but I reverted that as a test and still had the error). The strange part is that there is no error in viewing the list of Open or Closed batches, just the Exported batches. There are a lot of exported batches -- could the volume of batches be an issue here?
  
  The only error I've been able to track down is the popup error:
  
  > DataTables warning: table id=crm-batch-selector-5 - Ajax error. For more information about this error, please see <http://datatables.net/tn/7>
  
  ...and the one in the Drupal watchdog log:
  
  > Notice: Trying to get property of non-object in CRM\_Batch\_BAO\_Batch::getBatchList() (line 335 of /path-to-site/sites/all/modules/civicrm/CRM/Batch/BAO/Batch.php).
  
  ---
  
  * Drupal 7
  * CiviCRM 5.6.0
  * PHP 7.1
  
  **Tags:** batches
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2018-10-16. Score: 3 | Accepted answer
  
  Okay, solved. There was something awry with the latest Batch in that it had been exported, but the file didn't exist in the `custom` directory/filesystem. I changed that last batch status directly in the database from `5` (exported) to `2` (closed) and now the screens all load as usual.
  
  I suppose line 335 of `/path-to-site/sites/all/modules/civicrm/CRM/Batch/BAO/Batch.php` is trying to load information about this non-existent file and causes the error somehow, but I don't fully understand how.
  
  **EDIT**: The error recurred when we tried to re-export the problem batch, but I was able to get a more helpful error message this time:
  
  > Error: [] operator not supported for strings in CRM\_Financial\_BAO\_ExportFormat\_CSV->formatHeaders() (line 166 of /path-to-site/sites/all/modules/civicrm/CRM/Financial/BAO/ExportFormat/CSV.php).
  
  So this is in fact a PHP 7.1 bug. [Issue in lab is here](https://lab.civicrm.org/dev/core/issues/452). [PR is here](https://github.com/civicrm/civicrm-core/pull/12946).
  
  > **Comments:**
  > **username_3**: Above patch is merged & will be in the 5.8 release  
  
  ---
  
  ### Answer by username_1 on 2019-08-23. Score: 3
  
  I got a similar DataTables warning recently that prevented me from viewing exported batches. I was also able to change the batch status and see them in the 'closed' list. [running CiviCRM 5.13.5 and php 7.2 on WordPress]
  
  The problem turned out to be that I had recently deleted activities, including the export batch activities. Apparently, if so much as one export batch activity has been deleted, the list of exported batches will fail with a DataTables warning.
  
  I was able to fix the problem by manually changing the status of all exported batches to closed, then re-exporting them, thereby recreating activity records for the exported batches (fortunately, only 12 large batches of imported donations as we are still in the setup phase). I deleting the activity record for just one exported batch to verify that the problem is caused by one or more missing activity records for exported batches.
  
  This seems like a bug, since an activity record probably shouldn't be required to view the exported batch list (other type of activity can be safely deleted). I think the export activity record is somehow being used to link to the exported files in the [civicrm.files]/custom/ directory (though the exported files themselves can apparently be deleted without trouble if no longer needed).
  
  The actual functionality of the batches did not seem to be impaired (new batches and exports worked and I could search contributions on batch criteria).
  
  > **Comments:**
  > **username_2**: Do you know how to apply patches?  If so, could you please apply this patch and report back if it fixes your problem? https://github.com/civicrm/civicrm-core/pull/14367  
  > **username_2**: OK, I just replicated your problem and can confirm that this patch fixes it.  If you know how, you can apply it now to solve your problem immediately.  If not, I'll link this conversation to the patch in the hopes that it will aid the case for getting it included in CiviCRM.  
  > **username_1**: Thanks Jon.  I haven't learned how to apply a patch yet, but since you confirmed that it fixes my issue, I just won't delete batch activities for the time being...  
  > **username_2**: It just got merged into Civi 5.18, which comes out the first weekend in October.  You can upgrade then!  
  
  ---
  
  