When a module is installed / uninstalled, a decent status message ought to be displayed. Right now, all we get is 'configuration settings saved', which isn't terribly useful. Currently, a few modules tack on their own messages.

The attached patch is very likely incorrect in that the status messages are probably being displayed in the wrong place / function. However, opinions are welcome as to where exactly they should go.

Issues:
a) Should they be displayed for a Drupal (profile) install?
b) Would it be better for them to be displayed for hook_enable / hook_disable?
c) Should they be watchdogged as well?

-K

CommentFileSizeAuthor
#5 134849.patch1.86 KBroychri
#2 134849.patch1.63 KBroychri
install-message.patch1.56 KBZen

Comments

keith.smith’s picture

Status: Needs review » Needs work

:( patch no longer applies

# patch -p0 < install-message.patch
(Stripping trailing CRs from patch.)
patching file includes/install.inc
(Stripping trailing CRs from patch.)
patching file modules/system/system.module
Hunk #1 FAILED at 1789.
1 out of 1 hunk FAILED -- saving rejects to file modules/system/system.module.rej

roychri’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.63 KB

Rerolled patch for D7.

dries’s picture

Looks good to me, but not tested. I can commit this after a quick test.

webchick’s picture

Status: Needs review » Needs work

Hrm. The only thing is that this will cause module_enable and module_disable to always trigger dsm()s. This is not always what you want.

For example, if you are creating a custom install profile for hosted-drupal-service.com, all of a sudden your users are encountered with a bunch of "Blah blah module was installed" and they're going "Uh, what the heck is a module?"

I'd rather this logic be moved into the module enable form than internal API functions so we don't lose the flexibility to enable/disable/uninstall modules "silently" if we so choose.

roychri’s picture

Status: Needs work » Needs review
StatusFileSize
new1.86 KB

@webchick: Is this what you had in mind?

webchick’s picture

Status: Needs review » Needs work

Something exactly just like that, yes! :)

Now the only problem is that this patch breaks system.test's "Module list functionality" test. It's probably due to the string change.

dman’s picture

I'm in favor of this idea, and have been for a while : Display a note confirming that the module is installed and ready for action.
I'd agree that this automatic one may be better as part of the UI than the core.

I'd also like to see a link to a new modules settings and help pages added to the message ... but that may be a bit much to have as a global change. Could get verbose quick.
I'm just sick of Module that do something somewhere hidden on install and never tell me about it

.dan.

roychri’s picture

Status: Needs work » Needs review

@webchick: This new patch now modifies the system.test to take into consideration the text change. I ran the tests for system module and it passed.

moshe weitzman’s picture

looks good to me too

samirnassar’s picture

Patch works as advertised. +1

roychri’s picture

Status: Needs review » Reviewed & tested by the community

Thanks moshe weitzman and steamedpenguin for the testing.

catch’s picture

Status: Reviewed & tested by the community » Needs work

Still break system.test - looks like #8 never made it.

Jaza’s picture

Bump.

geerlingguy’s picture

Assigned: Zen » Unassigned
Issue summary: View changes
mlncn’s picture

Version: 7.x-dev » 10.1.x-dev

Some basics of this i think have gotten in, in the ensuing years. Presently enabling modules gives a Status message such as:

4 modules have been enabled: Dashboards, Dashboards statistics, Layout Builder, Statistics. Configure related permissions.
No configuration objects have been updated.

The related permissions part now has a link to a beautifully filtered set of permissions for only the relevant modules. (Thanks Benji and all!)

However, there is no mention of the configuration link— you would have to filter through the list of modules again to look at the module you just enabled to see if it now has a "Configuration" link.

Likewise, there is no link to help in the message.

Both configuration and help links should be included in the automatic notification about a module.

The same information should be presented when enabling modules with Drush. (Presently the modules / configuration objects text is, but no attempt at providing mention of or text versions of links for permissions.)

Also, i feel like there should also be a dedicated hook to provide additional information.

Presently any further information has to be given by setting a separate message:


/**
 * @file
 * Installation file for Example module.
 */

/**
 * Implements hook_install().
 */
function example_install() {
  $messenger = \Drupal::messenger();
  $messenger->addMessage(t('Module %module granted %permission permission to authenticated users.  In addition to adjusting the permissions if you wish and changing the default configuration, you will have to add X field and set the field widget to Example Widget.', ['%module' => 'Example', '%permission' => t('Example')]), 'status');
}

(For now i will update Module documentation guidelines - best practices with this modern Drupal code, it has Drupal 7 code for this already.)

Module development guides should affirmatively tell developers to add a custom message if there are important configuration or usage steps that are not already captured by the permissions or configure links.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.