You are here

function ServiceAuditFilesUsedNotManaged::_auditfiles_used_not_managed_get_file_list in Audit Files 8

Retrieves the file IDs to operate on.

Return value

array The file IDs.

File

src/ServiceAuditFilesUsedNotManaged.php, line 19
providing the service that used in 'used not managed' functionality.

Class

ServiceAuditFilesUsedNotManaged

Namespace

Drupal\auditfiles

Code

function _auditfiles_used_not_managed_get_file_list() {

  // Get all the file IDs in the file_usage table that are not in the
  // file_managed table.
  $connection = Database::getConnection();
  $config = \Drupal::config('auditfiles_config.settings');
  $query = 'SELECT DISTINCT fid FROM {file_usage} fu WHERE fid NOT IN (SELECT fid FROM {file_managed})';
  $maximum_records = $config
    ->get('auditfiles_report_options_maximum_records') ? $config
    ->get('auditfiles_report_options_maximum_records') : 250;
  if ($maximum_records > 0) {
    $query .= ' LIMIT ' . $maximum_records;
  }
  return $connection
    ->query($query)
    ->fetchCol();
}