- π³πΏNew Zealand quietone
Two core committers think this is best done in contrib. And combined with the lack of discussion for eight years I am closing this.
Thanks for the idea!
A problem my team frequently faces is revisiting a Drupal site that was developed by a third party (or developed by us in a previous lifetime) and figuring out whether modules that are enabled are really being used, and if so, where and how β to devise a strategy for site cleanup and upgrade.
Modules vary widely in functionality, and determining a module's behavior in a generic sense reduces to the Halting Problem, so this isn't really tractable to solve within a single contrib module or core β but rather it could be reasonably handled by specifying a light API in core, and asking modules to self-report their usage.
I'm defining in use as true when any of the following conditions are true:
Perhaps modules could implement a hook such as the following in the .install
file, next to the similar hook_requirements()
:
/**
* Report Comment module usage.
*
* @return
* An array describing the current usage of the Comment module.
*/
function comment_usage() {
$aspects = array();
// The Comment module is 'in use' if:
// - there are rows in {comment}
// (i.e., comments have actually been submitted, regardless of moderation)
// - or there are rows in {node} for which the comment field is COMMENT_NODE_OPEN
// (i.e., nodes exist upon which comments could be submitted)
$comments = db_query('SELECT COUNT(*) FROM {comment}')->fetchField();
$aspects['comments']['description'] = format_plural($count,'1 comment','@count comments');
if ($comments) {
$aspects['comments']['usage'] = USAGE_USED;
}
else {
$aspects['comments']['usage'] = USAGE_UNUSED;
}
$comments_allowed_on_nodes = db_query('SELECT COUNT(*) FROM {node} WHERE comment = :open', array(':open' => COMMENT_NODE_OPEN))->fetchField();
$aspects['comments_allowed_on_nodes']['description'] = format_plural($count,'1 commentable node','@count commentable nodes');
if ($comments_allowed_on_nodes) {
$aspects['comments_allowed_on_nodes']['usage'] = USAGE_USED;
}
else {
$aspects['comments_allowed_on_nodes']['usage'] = USAGE_UNUSED;
}
$usage = array();
$usage['comment'] = array(
'title' => t('Comment'),
'aspects' => $aspects,
);
return $usage;
}
...and then core could module_invoke_all()
and summarize the information either on admin/build/modules
or a MENU_LOCAL_TASK
thereunder. Perhaps an additional warning could be raised when the user tries to disable or uninstall a module that's USAGE_USED
.
A module-wide verdict could be established according to the following rules:
USAGE_USED
, or any of the aspects of the modules depending on this module are USAGE_USED
, the module-wide verdict is USAGE_USED
.USAGE_USED
, the module-wide verdict is USAGE_UNUSED
.Thoughts?
Closed: works as designed
11.0 π₯
base system
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Two core committers think this is best done in contrib. And combined with the lack of discussion for eight years I am closing this.
Thanks for the idea!