Added support for Zend Opcache
authorAlexander Ebert <ebert@woltlab.com>
Sat, 7 Dec 2013 20:52:57 +0000 (21:52 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 7 Dec 2013 20:52:57 +0000 (21:52 +0100)
wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php
wcfsetup/install/files/lib/system/WCF.class.php
wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php

index 3daaaa4fdaca0f1390628065073796783e4a241b..53e8c8f83c33dd7f71f837f5da35518e7207f147 100755 (executable)
@@ -120,6 +120,8 @@ class InstallPackageAction extends AbstractDialogAction {
                                // build redirect location
                                $location = $application->getPageURL() . 'acp/index.php/PackageList/' . SID_ARG_1ST;
                                
+                               WCF::resetZendOpcache();
+                               
                                // show success
                                $this->data = array(
                                        'currentAction' => $this->getCurrentAction(null),
@@ -130,6 +132,8 @@ class InstallPackageAction extends AbstractDialogAction {
                                return;
                        }
                        
+                       WCF::resetZendOpcache();
+                       
                        // continue with next node
                        $this->data = array(
                                'currentAction' => $this->getCurrentAction($queueID),
index dd891799f3c87835c0325bcce2673ac6f3ec2c7f..50fb7058f124eb16dd6745924ae7188c79f2ce65 100644 (file)
@@ -113,6 +113,12 @@ class WCF {
         */
        protected static $tplObj = null;
        
+       /**
+        * true if Zend Opcache is loaded and enabled
+        * @var boolean
+        */
+       protected static $zendOpcacheEnabled = null;
+       
        /**
         * Calls all init functions of the WCF class.
         */
@@ -732,6 +738,30 @@ class WCF {
                return $baseHref . $path;
        }
        
+       /**
+        * Resets Zend Opcache cache if installed and enabled.
+        * 
+        * @param       string          $script
+        */
+       public static function resetZendOpcache($script = '') {
+               if (self::$zendOpcacheEnabled === null) {
+                       if (extension_loaded('Zend Opcache') && @ini_get('opcache.enable')) {
+                               self::$zendOpcacheEnabled = true;
+                       }
+                       
+                       self::$zendOpcacheEnabled = false;
+               }
+               
+               if (self::$zendOpcacheEnabled) {
+                       if (empty($script)) {
+                               opcache_reset();
+                       }
+                       else {
+                               opcache_invalidate($script, true);
+                       }
+               }
+       }
+       
        /**
         * Returns style handler.
         * 
index 4cf66070bda7996782247afc397dff768375e454..0c45c306f1260508b8d6bd258926586264935f85 100644 (file)
@@ -4,6 +4,7 @@ use wcf\system\exception\SystemException;
 use wcf\system\io\File;
 use wcf\system\Callback;
 use wcf\system\Regex;
+use wcf\system\WCF;
 use wcf\util\DirectoryUtil;
 use wcf\util\FileUtil;
 
@@ -34,6 +35,8 @@ class DiskCacheSource implements ICacheSource {
                else {
                        $this->removeFiles('cache.'.$cacheName.'.php');
                }
+               
+               WCF::resetZendOpcache();
        }
        
        /**
@@ -41,6 +44,8 @@ class DiskCacheSource implements ICacheSource {
         */
        public function flushAll() {
                $this->getDirectoryUtil()->removePattern(new Regex('.*\.php$'));
+               
+               WCF::resetZendOpcache();
        }
        
        /**
@@ -73,6 +78,8 @@ class DiskCacheSource implements ICacheSource {
                // unset current DirectoryUtil object to make sure new cache file
                // can be deleted in the same request
                $this->directoryUtil = null;
+               
+               WCF::resetZendOpcache($this->getFilename($cacheName));
        }
        
        /**