[Piwik-svn] r393 - in trunk/plugins: Dashboard ExamplePlugin
svnmaster at piwik.org
svnmaster at piwik.org
Thu Mar 20 13:31:57 CET 2008
Author: matt
Date: 2008-03-20 13:31:55 +0100 (Thu, 20 Mar 2008)
New Revision: 393
Modified:
trunk/plugins/Dashboard/Dashboard.php
trunk/plugins/ExamplePlugin/ExamplePlugin.php
Log:
- fix #153 "After reinstalling piwik Dashboard plugin is not enabled"
Modified: trunk/plugins/Dashboard/Dashboard.php
===================================================================
--- trunk/plugins/Dashboard/Dashboard.php 2008-03-20 01:40:18 UTC (rev 392)
+++ trunk/plugins/Dashboard/Dashboard.php 2008-03-20 12:31:55 UTC (rev 393)
@@ -25,13 +25,27 @@
public function install()
{
- $sql = "CREATE TABLE ". Piwik::prefixTable('user_dashboard')." (
- login VARCHAR( 20 ) NOT NULL ,
- iddashboard INT NOT NULL ,
- layout TINYTEXT NOT NULL,
- PRIMARY KEY ( login , iddashboard )
- ) " ;
- Piwik_Query($sql);
+ // we catch the exception
+ try{
+ $sql = "CREATE TABLE ". Piwik::prefixTable('user_dashboard')." (
+ login VARCHAR( 20 ) NOT NULL ,
+ iddashboard INT NOT NULL ,
+ layout TINYTEXT NOT NULL,
+ PRIMARY KEY ( login , iddashboard )
+ ) " ;
+ Piwik_Query($sql);
+ } catch(Zend_Db_Statement_Exception $e){
+ // mysql code error 1050:table already exists
+ // see bug #153 http://dev.piwik.org/trac/ticket/153
+ if(ereg('1050',$e->getMessage()))
+ {
+ return;
+ }
+ else
+ {
+ throw $e;
+ }
+ }
}
public function uninstall()
Modified: trunk/plugins/ExamplePlugin/ExamplePlugin.php
===================================================================
--- trunk/plugins/ExamplePlugin/ExamplePlugin.php 2008-03-20 01:40:18 UTC (rev 392)
+++ trunk/plugins/ExamplePlugin/ExamplePlugin.php 2008-03-20 12:31:55 UTC (rev 393)
@@ -26,7 +26,16 @@
function install()
{
- Piwik_Query('ALTER TABLE '.Piwik::prefixTable('site'). " ADD `feedburnerName` VARCHAR( 100 ) NOT NULL ;");
+ try{
+ Piwik_Query('ALTER TABLE '.Piwik::prefixTable('site'). " ADD `feedburnerName` VARCHAR( 100 ) NOT NULL ;");
+ } catch(Zend_Db_Statement_Exception $e){
+ // mysql code error 1060: column already exists
+ // if there is another error we throw the exception, otherwise it is OK as we are simply reinstalling the plugin
+ if(!ereg('1060',$e->getMessage()))
+ {
+ throw $e;
+ }
+ }
}
function uninstall()
{
More information about the Piwik-svn
mailing list