[BUGFIX] Fix OpcodeCache for PHP 5.3 48/28048/4
authorAlexander Opitz <opitz.alexander@googlemail.com>
Tue, 4 Mar 2014 16:54:30 +0000 (17:54 +0100)
committerXavier Perseguers <xavier@typo3.org>
Tue, 4 Mar 2014 17:22:35 +0000 (18:22 +0100)
In PHP 5.3 anonymous functions can't be bound to static/self so an extra
call to a public function is needed.

Resolves: #56546
Related: #55252
Releases: 6.2
Change-Id: I56fc8c4ae92e50c35e972413540b43ec1fa714fc
Reviewed-on: https://review.typo3.org/28048
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Wouter Wolters
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/core/Classes/Utility/OpcodeCacheUtility.php

index efe6c73..8caf97c 100644 (file)
@@ -89,7 +89,7 @@ class OpcodeCacheUtility {
                                // Versions lower then 3.1.7 are known as malfunction
                                'error' => $apcVersion && VersionNumberUtility::convertVersionNumberToInteger($apcVersion) < 3001007,
                                'clearCallback' => function ($fileAbsPath) {
-                                       if (static::$supportedCaches['APC']['canInvalidate']) {
+                                       if (OpcodeCacheUtility::getCanInvalidate('APC')) {
                                                // This may output a warning like: PHP Warning: apc_delete_file(): Could not stat file
                                                // This warning isn't true, this means that apc was unable to generate the cache key
                                                // which depends on the configuration of APC.
@@ -164,6 +164,20 @@ class OpcodeCacheUtility {
        }
 
        /**
+        * Gets the state of canInvalidate for given cache system.
+        *
+        * @param string $system The cache system to test (APC, ...)
+        *
+        * @return boolean The calculated value from array or FALSE if cache system not exists.
+        * @internal Do not rely on this function. Will be removed if PHP5.4 is minimum requirement.
+        */
+       static public function getCanInvalidate($system) {
+               return isset(static::$supportedCaches[$system])
+                       ? static::$supportedCaches[$system]['canInvalidate']
+                       : FALSE;
+       }
+
+       /**
         * Clears a file from an opcache, if one exists.
         *
         * @param string $fileAbsPath The file as absolute path to be cleared.