[BUGFIX] Avoid non-blocking flock() calls Windows 26/40926/4
authorMarkus Klein <markus.klein@typo3.org>
Thu, 2 Jul 2015 13:26:06 +0000 (15:26 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 6 Jul 2015 21:27:22 +0000 (23:27 +0200)
Don't advertise the non-blocking capability of the
FileLockStrategy on Windows systems with PHP versions
below 5.5.23 or 5.6.7.
The non-blocking feature of flock() for Windows was
introduced with the aforementioned versions.

Resolves: #67916
Releases: master
Change-Id: I077f5fe39e237a689c3ad694f83a342b2cdb82c6
Reviewed-on: http://review.typo3.org/40926
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Locking/FileLockStrategy.php

index 53214d4..5f02532 100644 (file)
@@ -155,7 +155,14 @@ class FileLockStrategy implements LockingStrategyInterface {
                        // to protect files against other PHP scripts running in parallel threads of the same server instance!
                        return 0;
                }
-               $capabilities = self::LOCK_CAPABILITY_EXCLUSIVE | self::LOCK_CAPABILITY_SHARED | self::LOCK_CAPABILITY_NOBLOCK;
+               $capabilities = self::LOCK_CAPABILITY_EXCLUSIVE | self::LOCK_CAPABILITY_SHARED;
+               if (TYPO3_OS !== 'WIN'
+                       || version_compare(PHP_VERSION, '5.5.22', '>') && version_compare(PHP_VERSION, '5.6.0', '<')
+                       || version_compare(PHP_VERSION, '5.6.6', '>')
+               ) {
+                       $capabilities |= self::LOCK_CAPABILITY_NOBLOCK;
+               }
+
                return $capabilities;
        }