function simpletest_clean_temporary_directories

Find all leftover temporary directories and remove them.

1 call to simpletest_clean_temporary_directories()
simpletest_clean_environment in drupal/core/modules/simpletest/simpletest.module
Remove all temporary database tables and directories.

File

drupal/core/modules/simpletest/simpletest.module, line 480
Provides testing functionality.

Code

function simpletest_clean_temporary_directories() {
  $count = 0;
  if (is_dir('public://simpletest')) {
    $files = scandir('public://simpletest');
    foreach ($files as $file) {
      $path = 'public://simpletest/' . $file;
      if (is_dir($path) && (is_numeric($file) || strpos($file, 'config_simpletest') !== FALSE)) {
        file_unmanaged_delete_recursive($path, array(
          'Drupal\\simpletest\\TestBase',
          'filePreDeleteCallback',
        ));
        $count++;
      }
    }
  }
  if ($count > 0) {
    drupal_set_message(format_plural($count, 'Removed 1 temporary directory.', 'Removed @count temporary directories.'));
  }
  else {
    drupal_set_message(t('No temporary directories to remove.'));
  }
}