This only happens in the module administration page.

To reproduce this behaviour:
1. enable a module and one block provided by it - I.e. 'archive' module
2. disable the module
The block still shows up in the module administration page

I find this more funny than annoying and it happens only in module admin page.

Anyway, think it's and undesirable behaviour and should be addressed, maybe at the block management level.

CommentFileSizeAuthor
#9 system_block_rehash.patch510 bytestostinni
#4 system.module_5.diff3.54 KBdrumm

Comments

deekayen’s picture

I verified this in HEAD for the archive module.

tostinni’s picture

Status: Active » Needs work

This still apply to HEAD, the procedure to reproduce the bug is the right one.

However, I don't understand exactly why the block keep appears on this page, and not on the others pages. The problem is that looking at the blocks table, "archive" block stay there even if it doesn't appear on other pages (on module page yes it does). When I enter a new page, saying home, archive block isn't there but is still on the db.
The cache is flushed, because archive seems not to appear on the entry giving me the menu, but the current page keep the old cache entry (well I guess).

Ok so I proposed a radical way to correct this : rehashing blocks after saving the module configuration. So I just add a _block_rehash(); after the menu_rebuild();, it's a little dirty but do the trick. If you have any suggestion about a better way to do this ;)

function system_listing_save($edit = array()) {
  $op = $_POST['op'];
  $edit = $_POST['edit'];

  if ($op == t('Save configuration')) {
    db_query("UPDATE {system} SET status = 0 WHERE type = '%s'", $edit['type']);
    foreach ($edit['status'] as $name => $status) {
      // Make certain that the default theme is enabled to avoid user error
      if (($edit['type'] == 'theme') && ($edit['theme_default'] == $name)) {
        $status = 1;
      }

      db_query("UPDATE {system} SET status = %d, throttle = %d WHERE type = '%s' AND name = '%s'", $status, $edit['throttle'][$name], $edit['type'], $name);
    }

    if ($edit['type'] == 'theme') {
      variable_set('theme_default', $edit['theme_default']);
    }

    menu_rebuild();
    _block_rehash();

    drupal_set_message(t('The configuration options have been saved.'));
    drupal_goto($_GET['q']);
  }
}
drumm’s picture

Assigned: Unassigned » drumm

I can work on this.

drumm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.54 KB

I decided to implement a hook system for this. As a side effect:

- system_listing_save() only does database things. The UI things such as drupal_set_message() are now separated into the calling function.

- The status message for saving module is now:
* The aggregator module has been disabled.
* The archive module has been enabled.
instead of "The configuration options have been saved."

- The theme-specific things in system_listing_save() are not there anymore.

- There is also a hook called when modules are enabled.

I think I'll go write some documentation for the two new hooks now.

drumm’s picture

Here is some hook documentation:


/**
 * This hook is called on every module for when each new module is enabled. The
 * module will be loaded at this point so the module's own hook will be called
 * and other modules may use module_invoke() to call functions in the module.
 *
 * @param $module
 *   The name of the module which has just been enabled.
 */
hook_module_enabled($module) {
}

/**
 * This hook is called on every module for when each new module is disabled.
 * The module will still be loaded at this point so the module's own hook will
 * be called and other modules may use module_invoke() to call functions in the
 * module.
 *
 * @param $module
 *   The name of the module which has just been disabled. T
 */
hook_module_disabled($module) {
}

drumm’s picture

Status: Needs review » Needs work

This patch is now fubar. Please feel free to resubmit the concept in update #2 by tostinni in patch form.

tostinni’s picture

Sorry I didn't understood "This patch is now fubar." ?
This patch has been abandonned ?

drumm’s picture

Yes, I am not going to work on my approach currently. The patch was broken by the recent addition of multiple block regions. I may have time in the future.

I recomend making a real patch file for the simpler approach as describe in update #2.

tostinni’s picture

StatusFileSize
new510 bytes

Ok here goes the patch.

Uwe Hermann’s picture

Status: Needs work » Needs review

Patch still applies, but I didn't test it.

drumm’s picture

Assigned: drumm » Unassigned
Crell’s picture

Component: module system » base system
Status: Needs review » Closed (fixed)

I was unable to duplicate this using the instructions above. Setting to closed, unless someone else is still experiencing it.

attila-1’s picture

Version: » 4.7.11

The issue is still reproducible for Drupal 4.6 and Drupal 4.7.

The blocks of the last disabled module still remain displayed when the 'modules' page is accessed from the administration section.

I could not reproduce the issue on Drupal 5.20 and on Drupal 6.14