Skip to content
Snippets Groups Projects
Commit c8764a2c authored by Jared Hancock's avatar Jared Hancock
Browse files

Allow error to be set in plugin uninstall

If a plugin refuses to be uninstalled, allow it to set an error to be
displayed on the management page.
parent ba781964
No related branches found
No related tags found
No related merge requests found
...@@ -329,16 +329,18 @@ class Plugin { ...@@ -329,16 +329,18 @@ class Plugin {
* configuration for the plugin is also removed. If the plugin is * configuration for the plugin is also removed. If the plugin is
* reinstalled, it will have to be reconfigured. * reinstalled, it will have to be reconfigured.
*/ */
function uninstall() { function uninstall(&$errors) {
if ($this->pre_uninstall() === false) if ($this->pre_uninstall($errors) === false)
return false; return false;
$sql = 'DELETE FROM '.PLUGIN_TABLE $sql = 'DELETE FROM '.PLUGIN_TABLE
.' WHERE id='.db_input($this->getId()); .' WHERE id='.db_input($this->getId());
PluginManager::clearCache(); PluginManager::clearCache();
if (db_query($sql) && db_affected_rows()) if (!db_query($sql) || !db_affected_rows())
return $this->getConfig()->purge(); return false;
return false;
$this->getConfig()->purge();
return true;
} }
/** /**
...@@ -346,9 +348,8 @@ class Plugin { ...@@ -346,9 +348,8 @@ class Plugin {
* *
* Hook function to veto the uninstallation request. Return boolean * Hook function to veto the uninstallation request. Return boolean
* FALSE if the uninstall operation should be aborted. * FALSE if the uninstall operation should be aborted.
* TODO: Recommend a location to stash an error message if aborting
*/ */
function pre_uninstall() { function pre_uninstall(&$errors) {
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment