Added support for Zend Opcache
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / WCF.class.php
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.
         *