Permalink
Browse files

feature(core): added a CONFIG flag to control auto-disabling plugins

fixes #9009
  • Loading branch information...
jdalsem committed Mar 22, 2016
1 parent b96c736 commit 17363a50baf32ed0699673356e89e439eff961f0
View
@@ -103,6 +103,15 @@
*/
$CONFIG->system_cache_enabled;
/**
* Are unbootable plugins automatically disabled
*
* @see \Elgg\Database\Plugins->load
*
* @global string $CONFIG->auto_disable_plugins
*/
$CONFIG->auto_disable_plugins;
/**
* The site description from the current site object.
*
@@ -200,6 +200,19 @@
*/
$CONFIG->db_disable_query_cache = false;
/**
* Automatically disable plugins that are unable to boot
*
* Elgg will disable unbootable plugins. If you set this to false plugins
* will no longer be disabled if they are not bootable. This could cause requests
* to your site to fail as required views, classes or cached data could be missing.
*
* Setting this to false could be useful during deployment of new code.
*
* @global bool $CONFIG->auto_disable_plugins
*/
$CONFIG->auto_disable_plugins = true;
/**
* Minimum password length
*
@@ -8,7 +8,7 @@
/**
* Persistent, installation-wide key-value storage.
*
*
* WARNING: API IN FLUX. DO NOT USE DIRECTLY.
*
* @access private
@@ -206,9 +206,9 @@ function generateEntities() {
/**
* Cache a reference to this plugin by its ID
*
*
* @param \ElggPlugin $plugin
*
*
* @access private
*/
function cache(\ElggPlugin $plugin) {
@@ -376,11 +376,18 @@ function load() {
$plugin->start($start_flags);
$this->active_guids[$id] = $plugin->guid;
} catch (Exception $e) {
$plugin->deactivate();
$msg = _elgg_services()->translator->translate('PluginException:CannotStart',
array($id, $plugin->guid, $e->getMessage()));
elgg_add_admin_notice("cannot_start $id", $msg);
$return = false;
$disable_plugins = elgg_get_config('auto_disable_plugins');
if ($disable_plugins === null) {
$disable_plugins = true;
}
if ($disable_plugins) {
$plugin->deactivate();
$msg = _elgg_services()->translator->translate('PluginException:CannotStart',
array($id, $plugin->guid, $e->getMessage()));
elgg_add_admin_notice("cannot_start $id", $msg);
$return = false;
}
}
}
@@ -634,7 +641,7 @@ function getProvides($type = null, $name = null) {
/**
* Deletes all cached data on plugins being provided.
*
*
* @return boolean
* @access private
*/
@@ -24,10 +24,16 @@
foreach ($installed_plugins as $id => $plugin) {
if (!$plugin->isValid()) {
if ($plugin->isActive()) {
// force disable and warn
elgg_add_admin_notice('invalid_and_deactivated_' . $plugin->getID(),
elgg_echo('ElggPlugin:InvalidAndDeactivated', array($plugin->getId())));
$plugin->deactivate();
$disable_plugins = elgg_get_config('auto_disable_plugins');
if ($disable_plugins === null) {
$disable_plugins = true;
}
if ($disable_plugins) {
// force disable and warn
elgg_add_admin_notice('invalid_and_deactivated_' . $plugin->getID(),
elgg_echo('ElggPlugin:InvalidAndDeactivated', array($plugin->getId())));
$plugin->deactivate();
}
}
continue;
}

0 comments on commit 17363a5

Please sign in to comment.