1.20.x system.admin.inc system_transliteration_file_query()

Builds a query that returns all file names from the database containing non-ASCII characters.

Return value

SelectQuery:

File

modules/system/system.admin.inc, line 2801
Admin page callbacks for the System module.

Code

function system_transliteration_file_query() {
  $operator = 'NOT REGEXP';
  $regex = '/[a-z0-9_.-]+$';

  if (config_get('system.core', 'file_transliterate_lowercase')) {
    // As of version 8.0.22 MySQL throws an error on binary comparison, but
    // recent versions support setting a flag for case sensitive comparison in
    // the regex.
    $connection = Database::getConnection();
    if ($connection->databaseType() == 'mysql' && version_compare($connection->version(), '8.0.22', '>=')) {
      $regex = '/(?-i)[a-z0-9_.-]+$';
    }
    else {
      $operator .= ' BINARY';
    }
  }

  return db_select('file_managed')
    ->fields('file_managed')
    ->condition('uri', $regex, $operator);
}