function update_clear_update_disk_cache

Same name in other branches
  1. 7.x modules/update/update.module \update_clear_update_disk_cache()
  2. 9 core/modules/update/update.module \update_clear_update_disk_cache()
  3. 8.9.x core/modules/update/update.module \update_clear_update_disk_cache()
  4. 11.x core/modules/update/update.module \update_clear_update_disk_cache()

Clears the temporary files and directories based on file age from disk.

2 calls to update_clear_update_disk_cache()
UpdateMiscTest::testClearDiskCache in core/modules/update/tests/src/Functional/UpdateMiscTest.php
Checks that clearing the disk cache works.
update_cron in core/modules/update/update.module
Implements hook_cron().

File

core/modules/update/update.module, line 660

Code

function update_clear_update_disk_cache() {
    // List of update module cache directories. Do not create the directories if
    // they do not exist.
    $directories = [
        _update_manager_cache_directory(FALSE),
        _update_manager_extract_directory(FALSE),
    ];
    // Search for files and directories in base folder only without recursion.
    foreach ($directories as $directory) {
        if (is_dir($directory)) {
            \Drupal::service('file_system')->scanDirectory($directory, '/.*/', [
                'callback' => 'update_delete_file_if_stale',
                'recurse' => FALSE,
            ]);
        }
    }
}

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