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 {
* configuration for the plugin is also removed. If the plugin is
* reinstalled, it will have to be reconfigured.
*/
function uninstall() {
if ($this->pre_uninstall() === false)
function uninstall(&$errors) {
if ($this->pre_uninstall($errors) === false)
return false;
$sql = 'DELETE FROM '.PLUGIN_TABLE
.' WHERE id='.db_input($this->getId());
PluginManager::clearCache();
if (db_query($sql) && db_affected_rows())
return $this->getConfig()->purge();
return false;
if (!db_query($sql) || !db_affected_rows())
return false;
$this->getConfig()->purge();
return true;
}
/**
......@@ -346,9 +348,8 @@ class Plugin {
*
* Hook function to veto the uninstallation request. Return boolean
* 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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment