NEW Add check if the file object exists
- there might be instances where a file path exists on record but the physical file is not which would throw an exception and break the job. To avoid this scenario, we have to make sure that both record and physical file exists before proceeding with the delete process.
This commit is contained in:
parent
3e6f191dc3
commit
9e7c016b66
|
@ -185,18 +185,20 @@ class BulkDeleteFormSubmissionsJob extends AbstractQueuedJob
|
|||
if ($fileList->exists()) {
|
||||
$fileList->each(function($file) use(&$counter) {
|
||||
/* @var $file File */
|
||||
// delete file from the asset store
|
||||
$file->deleteFile();
|
||||
if ($file->exists()) {
|
||||
// delete file from the asset store
|
||||
$file->deleteFile();
|
||||
|
||||
// check if file has live version
|
||||
if ($file->isPublished()) {
|
||||
$file->doUnpublish();
|
||||
// check if file has live version
|
||||
if ($file->isPublished()) {
|
||||
$file->doUnpublish();
|
||||
}
|
||||
|
||||
// remove the DB record of this file
|
||||
$file->delete();
|
||||
|
||||
$counter += 1;
|
||||
}
|
||||
|
||||
// remove the DB record of this file
|
||||
$file->delete();
|
||||
|
||||
$counter += 1;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue