From fcfea531f4c823eea30b06f957903ad8546dbfc8 Mon Sep 17 00:00:00 2001 From: mattpiwik <matthieu.aubry@gmail.com> Date: Wed, 30 Jun 2010 15:25:25 +0000 Subject: [PATCH] Fixes #1438 Smarty template_c files should be purged on plugin install/uninstall git-svn-id: http://dev.piwik.org/svn/trunk@2403 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- core/PluginsManager.php | 4 +++- core/View.php | 22 ++++++++++++---------- plugins/CoreUpdater/Controller.php | 1 + plugins/Installation/Controller.php | 1 + 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/PluginsManager.php b/core/PluginsManager.php index 9f344aa922..577a66bfdf 100644 --- a/core/PluginsManager.php +++ b/core/PluginsManager.php @@ -121,6 +121,7 @@ class Piwik_PluginsManager // Delete merged js/css files to force regenerations to exclude the deactivated plugin Piwik_AssetManager::removeMergedAssets(); + Piwik_View::clearCompiledTemplates(); } public function installLoadedPlugins() @@ -160,7 +161,8 @@ class Piwik_PluginsManager Zend_Registry::get('config')->Plugins = $plugins; // Delete merged js/css files to force regenerations to include the activated plugin - Piwik_AssetManager::removeMergedAssets(); + Piwik_AssetManager::removeMergedAssets(); + Piwik_View::clearCompiledTemplates(); } public function loadPlugins( array $pluginsToLoad ) diff --git a/core/View.php b/core/View.php index 7ea936d7a1..443950d851 100644 --- a/core/View.php +++ b/core/View.php @@ -201,9 +201,10 @@ class Piwik_View implements Piwik_iView /** * Clear compiled Smarty templates */ - public function clearCompiledTemplates() + static public function clearCompiledTemplates() { - $this->smarty->clear_compiled_tpl(); + $view = Piwik_View::factory(); + $view->smarty->clear_compiled_tpl(); } /* @@ -215,8 +216,6 @@ class Piwik_View implements Piwik_iView } return false; } - - public function setCaching($caching) { $this->smarty->caching = $caching; @@ -271,7 +270,7 @@ class Piwik_View implements Piwik_iView * @param $templateName Template name (e.g., 'index') * @param $viewType View type (e.g., Piwik_View::CLI) */ - static public function factory( $templateName, $viewType = null) + static public function factory( $templateName = null, $viewType = null) { Piwik_PostEvent('View.getViewType', $viewType); @@ -320,12 +319,15 @@ class Piwik_View implements Piwik_iView if($viewType != self::MOBILE) { $templateFile = $path.'/templates/'.$templateName.'.tpl'; - if(!file_exists($templateFile)) - { - throw new Exception('Template not found: '.$templateFile); - } } - + + // Specified template not found + // We allow for no specified template + if(!empty($templateName) + && !file_exists($templateFile)) + { + throw new Exception('Template not found: '.$templateFile); + } return new Piwik_View($templateFile); } } diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index 91e83ffd88..2952d40c3e 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -298,6 +298,7 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller { // Delete merged js/css files to force regenerations based on new versions of css/js files Piwik_AssetManager::removeMergedAssets(); + Piwik_View::clearCompiledTemplates(); $this->loadAndExecuteUpdateFiles($updater, $componentsWithUpdateFile); diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index a8eea9bd55..ff2dde3eb1 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -74,6 +74,7 @@ class Piwik_Installation_Controller extends Piwik_Controller { // Delete merged js/css files to force regenerations based on updated activated plugin list Piwik_AssetManager::removeMergedAssets(); + Piwik_View::clearCompiledTemplates(); $view = new Piwik_Installation_View( $this->pathView . 'welcome.tpl', -- GitLab