[BUGFIX] Close file resource in FileLockStrategy if acquire failed 31/60531/4
authorMarkus Klein <markus.klein@typo3.org>
Wed, 24 Apr 2019 16:49:43 +0000 (18:49 +0200)
committerSusanne Moog <look@susi.dev>
Fri, 26 Apr 2019 08:15:16 +0000 (10:15 +0200)
commit2043c6d4f39f05fb60752a37ca7b12afbe3264d0
tree756c418ecfa8d5125b716eb9f01c411a9aefcba8
parentb4f5e045746235d57ab89a1eb1f56761ca9bac6b
[BUGFIX] Close file resource in FileLockStrategy if acquire failed

When acquiring a lock via the FileLockStrategy it is very important
to close the underlying file handle again, if the acquire action failed.

The same instance of the FileLockStrategy might be reused later
(e.g. in TSFE) again, whereas the (still open) file could have been
deleted meanwhile. The file handle would be invalid and another try
to open the same file again - with fopen() - may fail.
The behaviour of PHP's fopen() is different depending on the actual
file storage. Currently things fail on host-mounted drives in
containers in Docker for Windows.

Resolves: #88197
Releases: master, 9.5, 8.7
Change-Id: If802c670b617119d28aca09fcd5acef95f0ae678
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60531
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Johannes Kasberger <johannes.kasberger@reelworx.at>
Reviewed-by: Susanne Moog <look@susi.dev>
typo3/sysext/core/Classes/Locking/FileLockStrategy.php