48 $subQuery = AttachedObjectTable::query()
54 ->setSelect([
'DISK_FILE_ID'])
55 ->where(
'DATE_CREATE',
'<', $this->dateExpired)
56 ->whereIn(
'SOURCE', self::SOURCE_MUST_BE_ATTACHED)
57 ->whereExpr(
"NOT EXISTS ({$subQuery->getQuery()})", [
'DISK_FILE_ID'])
58 ->setLimit(self::LIMIT_SELECT_UNATTACHED_FILES)
62 $diskFilesIds = array_column($unattachedFiles,
'DISK_FILE_ID');
64 if (empty($diskFilesIds))
69 $diskFiles = File::getModelList([
'filter' => Query::filter()->whereIn(
'ID', $diskFilesIds)]);
71 foreach ($diskFiles as $diskFile)
73 $diskFile->delete(SystemUser::SYSTEM_USER_ID);