diff options
author | Stefan Giehl <stefan@piwik.org> | 2017-08-03 08:13:37 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2017-08-03 08:13:37 +0300 |
commit | 2437cedbc9060b916acb3a613dcca0567e7e6d14 (patch) | |
tree | 6b6da45c6772b17bf61a30a9f393321d7352a37a /core | |
parent | 287320647e09592d02635d19e3b173c8f468ee1f (diff) |
Ignore table not found errors when removing plugin or measurable settings (#11881)
Diffstat (limited to 'core')
-rw-r--r-- | core/Settings/Storage/Backend/MeasurableSettingsTable.php | 22 | ||||
-rw-r--r-- | core/Settings/Storage/Backend/PluginSettingsTable.php | 22 |
2 files changed, 36 insertions, 8 deletions
diff --git a/core/Settings/Storage/Backend/MeasurableSettingsTable.php b/core/Settings/Storage/Backend/MeasurableSettingsTable.php index 22452288c8..e91a7ac9cd 100644 --- a/core/Settings/Storage/Backend/MeasurableSettingsTable.php +++ b/core/Settings/Storage/Backend/MeasurableSettingsTable.php @@ -150,8 +150,15 @@ class MeasurableSettingsTable implements BackendInterface */ public static function removeAllSettingsForSite($idSite) { - $query = sprintf('DELETE FROM %s WHERE idsite = ?', Common::prefixTable('site_setting')); - Db::query($query, array($idSite)); + try { + $query = sprintf('DELETE FROM %s WHERE idsite = ?', Common::prefixTable('site_setting')); + Db::query($query, array($idSite)); + } catch (Exception $e) { + if ($e->getCode() != 42) { + // ignore table not found error, which might occur when updating from an older version of Piwik + throw $e; + } + } } /** @@ -161,7 +168,14 @@ class MeasurableSettingsTable implements BackendInterface */ public static function removeAllSettingsForPlugin($pluginName) { - $query = sprintf('DELETE FROM %s WHERE plugin_name = ?', Common::prefixTable('site_setting')); - Db::query($query, array($pluginName)); + try { + $query = sprintf('DELETE FROM %s WHERE plugin_name = ?', Common::prefixTable('site_setting')); + Db::query($query, array($pluginName)); + } catch (Exception $e) { + if ($e->getCode() != 42) { + // ignore table not found error, which might occur when updating from an older version of Piwik + throw $e; + } + } } } diff --git a/core/Settings/Storage/Backend/PluginSettingsTable.php b/core/Settings/Storage/Backend/PluginSettingsTable.php index 87476ff8fb..0f49d6b68e 100644 --- a/core/Settings/Storage/Backend/PluginSettingsTable.php +++ b/core/Settings/Storage/Backend/PluginSettingsTable.php @@ -155,8 +155,15 @@ class PluginSettingsTable implements BackendInterface throw new Exception('No userLogin specified. Cannot remove all settings for this user'); } - $table = Common::prefixTable('plugin_setting'); - Db::get()->query(sprintf('DELETE FROM %s WHERE user_login = ?', $table), array($userLogin)); + try { + $table = Common::prefixTable('plugin_setting'); + Db::get()->query(sprintf('DELETE FROM %s WHERE user_login = ?', $table), array($userLogin)); + } catch (Exception $e) { + if ($e->getCode() != 42) { + // ignore table not found error, which might occur when updating from an older version of Piwik + throw $e; + } + } } /** @@ -169,7 +176,14 @@ class PluginSettingsTable implements BackendInterface */ public static function removeAllSettingsForPlugin($pluginName) { - $table = Common::prefixTable('plugin_setting'); - Db::get()->query(sprintf('DELETE FROM %s WHERE plugin_name = ?', $table), array($pluginName)); + try { + $table = Common::prefixTable('plugin_setting'); + Db::get()->query(sprintf('DELETE FROM %s WHERE plugin_name = ?', $table), array($pluginName)); + } catch (Exception $e) { + if ($e->getCode() != 42) { + // ignore table not found error, which might occur when updating from an older version of Piwik + throw $e; + } + } } } |