Function _modules_weight_modules_list uses drupal_sort_weight() to sort the module list, but that function does not take module name into account resulting in a list that is not correct.

The function needs to be replaced with a function that also considers module name, such as this:

  // Sorting all modules by their weight.               <<---- remove
//  uasort($modules, 'drupal_sort_weight');           <<---- remove
  // Sorting all modules by their weight and name.
  uasort($modules, '_modules_weight_sort_weight');

  return $modules;
}

function _modules_weight_sort_weight($a, $b) {
  $a_weight = is_array($a) && isset($a['weight']) ? $a['weight'] : 0;
  $b_weight = is_array($b) && isset($b['weight']) ? $b['weight'] : 0;
  if ($a_weight == $b_weight) {
    return ($a['name'] < $b['name'] ? -1 : 1);
  }
  return $a_weight < $b_weight ? -1 : 1;
}

Sorry, I do not currently have an environment to produce a proper patch.

Comments

NancyDru created an issue. See original summary.

adriancid’s picture

Title: Drupal_sort_weight is not what is needed » Sort the modules list by weight and name
Assigned: Unassigned » adriancid

Hi @NancyDru, thanks for reporting this issue.

  • adriancid committed be1e32f on 8.x-1.x authored by NancyDru
    Issue #2933083 by NancyDru, adriancid: Sort the modules list by weight...
adriancid’s picture

Version: 7.x-1.9 » 8.x-1.x-dev
Status: Active » Patch (to be ported)
adriancid’s picture

Status: Patch (to be ported) » Fixed

  • adriancid committed acfbe18 on 7.x-1.x
    Issue #2933083 by adriancid, NancyDru: Sort the modules list by weight...

  • adriancid committed df89373 on 7.x-1.x
    Issue #2933083 by adriancid, NancyDru: Sort the modules list by weight...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.