Issue Bug Closed

#97515filemtime() of FileSessionHandler.php should be silent

Alexander Rotzsch 04/29/22, 09:57 updated 12/02/25, 14:33

Description

Hi,

I encountered several errors like this after our own crawler runs through all pages of our intranet:

Core: Error handler (FE): PHP Warning: filemtime(): stat failed for /var/www/intranet/var/session/d7d439161737edaa72aa09938771f17c4fd208af/hash_6541a8ee794d962b4d07f99a08ba3992 in /var/www/intranet/public/typo3/sysext/install/Classes/Service/Session/FileSessionHandler.php line 184

The causing line is here:

https://github.com/TYPO3/typo3/blob/bbc8676ba09c058d7b6f6d595e5931333f48b993/typo3/sysext/install/Classes/Service/Session/FileSessionHandler.php#L184

What I found out after a lot of testing: The method reads the session hash directory and does some time comparison. Unfortunately when a lot of crawls take place in very short periods, filemtime() tries to read a hash file that is already deleted by another call of the gc(int $maxLifeTime) method.

Solution: @filemtime() instead of filemtime()

In the core, there are several places where an “@” is prepended to filemtime(), so it might be a good idea to prepend it there too. Same of course goes for other file methods that are similar.

https://www.php.net/manual/de/function.filemtime.php

Reviews 2

History 810

  1. Alexander Rotzsch commented 04/29/22, 10:59

    Correction: … so it might be a good idea to prepend it at other places, too.

  2. Andreas Kienast changed Sprint Focus On Location Sprint 08/05/22, 09:44

  3. Oliver Hader changed Sprint Focus On Location Sprint 11/03/22, 09:04

  4. Benni Mack changed Sprint Focus Stabilization Sprint 06/06/23, 12:59

  5. Łukasz Uznański commented 10/02/23, 15:55

    Is muting filemtime call a preferred solution?

  6. Alexander Rotzsch commented 02/06/25, 07:15

    The warning (and lots of BE logs) is still there in TYPO3 12 + 13.

  7. Gerrit Code Review pushed patch set 1 for main to change 88769 status New Under Review 03/26/25, 11:54

  8. Gerrit Code Review pushed patch set 1 for 13.4 to change 88781 03/26/25, 20:32

  9. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % 03/26/25, 20:35

    Applied in changeset commit:eb489dbdaa0571e56f1262b4dd65c8949e6dc488.

  10. Benni Mack changed status Resolved Closed 12/02/25, 14:33