I suspect this is a duplicate bug report, but I searched and couldn't find anything, so I'm submitting this...

I just noticed on a new D7 test site I'm building that the order of things at admin/modules is somewhat non-deterministic. It appears that we start with a completely alphabetized list of module names, and as we process them, we stick them into buckets for each "Package" they belong to. But the resulting Package buckets remain in whatever order we defined them in, the packages themselves are not sorted, and therefore the package groupings are non-deterministic on the admin/modules page as you add new modules. Some examples to reproduce and see this in action:

A) Start with core. Then add http://drupal.org/project/advanced_help -- since "advanced_help" is earlier in the alphabet than "aggregator", you'll now have your "Other" package listed above "Core".

B) Install both http://drupal.org/project/cvs_deploy and http://drupal.org/project/group -- since "CVS" is earlier than "group" in the alphabet, your order of packages will be Core, Other, Group

It seems like we should really sort the package fieldsets themselves by name, so that you get consistent ordering, regardless of the module names on your site.

CommentFileSizeAuthor
#2 810484.patch595 bytesNick Lewis

Comments

Nick Lewis’s picture

Yeah you're right. And this is a regression... *I think* ... D6 has package alphabetizing correct... well, except for case tracker vs cck... (don't even want to know).

Pretty sure i got this one figured out.

In D7 the order is governed by the order of this array and how the formapi eventually *deals* with it. http://api.drupal.org/api/function/system_modules/7 (system.admin.inc line 933)

// Add basic information to the fieldsets.
  foreach (element_children($form['modules']) as $package) {
    $form['modules'][$package] += array(
      '#type' => 'fieldset',
      '#title' => t($package),
      '#collapsible' => TRUE,
      '#theme' => 'system_modules_fieldset',
      '#header' => array(
        array('data' => t('Enabled'), 'class' => array('checkbox')),
        t('Name'),
        t('Version'),
        t('Description'),
        array('data' => t('Operations'), 'colspan' => 3),
      ),
    );
  }

What's missing was a little thing that a seemingly killed theme function did in d6 http://api.drupal.org/api/function/theme_system_modules/6

That ksort right there is all that appears to be missing. The question is what impact ksort would have on a form array - given that this is merely a theme function... if you don't hear back from me, it means it wasn't good.

  foreach ($modules as $module) {
    if (!isset($module->info['package']) || !$module->info['package']) {
      $module->info['package'] = t('Other');
    }
    $packages[$module->info['package']][$module->name] = $module->info;
  }
  ksort($packages);

  // Display packages.
  $output = '';
  foreach ($packages as $package => $modules) {
Nick Lewis’s picture

Status: Active » Needs review
StatusFileSize
new595 bytes

Nothing appears to have blown up. Lets see what testbot thinks.

damien tournoud’s picture

Status: Needs review » Closed (duplicate)
Nick Lewis’s picture

@dww yeah about search... lol :-D