Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FileProfilerStorage.php

function FileProfilerStorage::removeExpiredProfiles

1 call to FileProfilerStorage::removeExpiredProfiles()
FileProfilerStorage::write in vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php

File

vendor/symfony/http-kernel/Profiler/FileProfilerStorage.php, line 316

Class

FileProfilerStorage
Storage for profiler using files.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

private function removeExpiredProfiles() : void {
    $minimalProfileTimestamp = time() - 2 * 86400;
    $file = $this->getIndexFilename();
    $handle = fopen($file, 'r');
    if ($offset = is_file($file . '.offset') ? (int) file_get_contents($file . '.offset') : 0) {
        fseek($handle, $offset);
    }
    while ($line = fgets($handle)) {
        $values = str_getcsv($line, ',', '"', '\\');
        if (7 > \count($values)) {
            // skip invalid lines
            $offset += \strlen($line);
            continue;
        }
        [
            $csvToken,
            ,
            ,
            ,
            $csvTime,
        ] = $values;
        if ($csvTime >= $minimalProfileTimestamp) {
            break;
        }
        @unlink($this->getFilename($csvToken));
        $offset += \strlen($line);
    }
    fclose($handle);
    file_put_contents($file . '.offset', $offset);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal