Question

I have been debugging a bit an issue on our platform and I notice that our scanDirectory takes, from time to time, way to long, more than 100seconds. I have been looking at the default.settings.php and I noticed

/**
 * The default list of directories that will be ignored by Drupal's file API.
 *
 * By default ignore node_modules and bower_components folders to avoid issues
 * with common frontend tools and recursive scanning of directories looking for
 * extensions.
 *
 * @see file_scan_directory()
 * @see \Drupal\Core\Extension\ExtensionDiscovery::scanDirectory()
 */
$settings['file_scan_ignore_directories'] = [
  'node_modules',
  'bower_components',
  'vendor',
];

I found that out that our sites/default directory is the one to blame. Can I just add it here? Or should I include the subdirectories(fx sites/default/files)?

I am really surprised about this one. Been working with drupal years now and I see this first time!

Was it helpful?

Solution

If you need the file_scan_ignore_directories setting changed, you should add the $settings['file_scan_ignore_directories'] assignment in your settings.php, not default.settings.php lest it's overwritten when you update Drupal core.

Regarding what path strings to add to $settings['file_scan_ignore_directories'], that's up to you. As the comment block states, that setting affects all calls to ExtensionDiscovery::scanDirectory() and FileSystem::scanDirectory() (if a nomask option isn't specified).

Add the most inclusive path that you know will never contain extensions or files to be scanned/discovered.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top