public function MTimeProtectedFastFileStorage::garbageCollection
public MTimeProtectedFastFileStorage::garbageCollection()
Performs garbage collection on the storage.
The storage may choose to delete expired or invalidated items.
Overrides FileStorage::garbageCollection
File
- core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php, line 150
Class
- MTimeProtectedFastFileStorage
- Stores PHP code in files with securely hashed names.
Namespace
Drupal\Component\PhpStorageCode
public function garbageCollection() { $flags = \FilesystemIterator::CURRENT_AS_FILEINFO; $flags += \FilesystemIterator::SKIP_DOTS; foreach ($this->listAll() as $name) { $directory = $this->getContainingDirectoryFullPath($name); try { $dir_iterator = new \FilesystemIterator($directory, $flags); } catch (\UnexpectedValueException $e) { // FilesystemIterator throws an UnexpectedValueException if the // specified path is not a directory, or if it is not accessible. continue; } $directory_unlink = TRUE; $directory_mtime = filemtime($directory); foreach ($dir_iterator as $fileinfo) { if ($directory_mtime > $fileinfo->getMTime()) { // Ensure the folder is writable. @chmod($directory, 0777); @unlink($fileinfo->getPathName()); } else { // The directory still contains valid files. $directory_unlink = FALSE; } } if ($directory_unlink) { $this->unlink($name); } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!PhpStorage!MTimeProtectedFastFileStorage.php/function/MTimeProtectedFastFileStorage::garbageCollection/8.1.x