From: Alexander Ebert Date: Sat, 7 Dec 2013 20:52:57 +0000 (+0100) Subject: Added support for Zend Opcache X-Git-Tag: 2.0.0~8^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f6619df8c9e31a6e56d8f31b5b14ab213ee0bcfe;p=GitHub%2FWoltLab%2FWCF.git Added support for Zend Opcache --- diff --git a/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php b/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php index 3daaaa4fda..53e8c8f83c 100755 --- a/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php @@ -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), diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index dd891799f3..50fb7058f1 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -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. * diff --git a/wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php b/wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php index 4cf66070bd..0c45c306f1 100644 --- a/wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php +++ b/wcfsetup/install/files/lib/system/cache/source/DiskCacheSource.class.php @@ -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)); } /**