[BUGFIX] Fix clear_cache for XCache < 3.0 41/32441/2
authorAlexander Opitz <opitz.alexander@googlemail.com>
Wed, 27 Aug 2014 16:03:37 +0000 (18:03 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Mon, 8 Sep 2014 09:59:50 +0000 (11:59 +0200)
The XCache API changed with version 3.0. Ubuntu 12.04 uses XCache
version 1.3.2 so we need to support the old API.

Resolves: #61175
Releases: 6.3, 6.2
Change-Id: I76e975222747c965c5ef6e062231209d398a1c15
Reviewed-on: http://review.typo3.org/32441
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Utility/OpcodeCacheUtility.php

index f45849d..344b3a9 100644 (file)
@@ -41,6 +41,7 @@ class OpcodeCacheUtility {
         */
        static protected function initialize() {
                $apcVersion = phpversion('apc');
+               $xcVersion = phpversion('xcache');
 
                static::$supportedCaches = array(
                        // The ZendOpcache aka OPcache since PHP 5.5
@@ -107,15 +108,26 @@ class OpcodeCacheUtility {
                        // http://xcache.lighttpd.net/
                        'XCache' => array(
                                'active' => extension_loaded('xcache'),
-                               'version' => phpversion('xcache'),
+                               'version' => $xcVersion,
                                'canReset' => TRUE, // xcache_clear_cache()
                                'canInvalidate' => FALSE,
                                'error' => FALSE,
-                               'clearCallback' => function ($fileAbsPath) {
-                                       if (!ini_get('xcache.admin.enable_auth')) {
-                                               xcache_clear_cache(XC_TYPE_PHP);
-                                       }
-                               }
+                               // API changed with XCache 3.0.0
+                               // http://xcache.lighttpd.net/wiki/XcacheApi?action=diff&version=23&old_version=22
+                               'clearCallback' => (
+                                       $xcVersion && VersionNumberUtility::convertVersionNumberToInteger($xcVersion) < 3000000 ?
+                                               function ($fileAbsPath) {
+                                                       if (!ini_get('xcache.admin.enable_auth')) {
+                                                               xcache_clear_cache(XC_TYPE_PHP, 0);
+                                                       }
+                                               }
+                                               :
+                                               function ($fileAbsPath) {
+                                                       if (!ini_get('xcache.admin.enable_auth')) {
+                                                               xcache_clear_cache(XC_TYPE_PHP);
+                                                       }
+                                               }
+                               )
                        ),
 
                        // https://github.com/eaccelerator/eaccelerator