function _drupal_file_scan_cache

Returns the current list of cached file system scan results.

Return value

An associative array tracking the most recent file scan results for all files that have had scans performed. The keys are the type and name of the item that was searched for, and the values can be either:

  • Boolean FALSE if the item was not found in the file system.
  • A string pointing to the location where the item was found.
4 calls to _drupal_file_scan_cache()
BootstrapGetFilenameTestCase::testDrupalGetFilename in modules/simpletest/tests/bootstrap.test
Test that drupal_get_filename() works correctly when the file is not found in the database.
BootstrapGetFilenameWebTestCase::testDrupalGetFilename in modules/simpletest/tests/bootstrap.test
Test that drupal_get_filename() works correctly with a full Drupal site.
drupal_file_scan_write_cache in includes/bootstrap.inc
Writes the file scan cache to the persistent cache.
_drupal_get_filename_fallback in includes/bootstrap.inc
Performs a cached file system scan as a fallback when searching for a file.
3 string references to '_drupal_file_scan_cache'
BootstrapGetFilenameWebTestCase::testDrupalGetFilename in modules/simpletest/tests/bootstrap.test
Test that drupal_get_filename() works correctly with a full Drupal site.
drupal_file_scan_write_cache in includes/bootstrap.inc
Writes the file scan cache to the persistent cache.
system_list_reset in includes/module.inc
Resets all system_list() caches.

File

includes/bootstrap.inc, line 1031

Code

function &_drupal_file_scan_cache() {
    $file_scans =& drupal_static(__FUNCTION__, array());
    // The file scan results are stored in a persistent cache (in addition to the
    // static cache) but because this function can be called before the
    // persistent cache is available, we must merge any items that were found
    // earlier in the page request into the results from the persistent cache.
    if (!isset($file_scans['#cache_merge_done'])) {
        try {
            if (function_exists('cache_get')) {
                $cache = cache_get('_drupal_file_scan_cache', 'cache_bootstrap');
                if (!empty($cache->data)) {
                    // File scan results from the current request should take precedence
                    // over the results from the persistent cache, since they are newer.
                    $file_scans = drupal_array_merge_deep($cache->data, $file_scans);
                }
                // Set a flag to indicate that the persistent cache does not need to be
                // merged again.
                $file_scans['#cache_merge_done'] = TRUE;
            }
        } catch (Exception $e) {
            // Hide the error.
        }
    }
    return $file_scans;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.