Installation profiles are sorted on the order that the files are found, which can be very random (seems to be by file creation date?). They ought to sort alphabetically instead.

Comments

webchick’s picture

Status: Active » Needs review
StatusFileSize
new677 bytes

This sorts them by profile machine name, which is not ideal, but better than no sort whatsoever. I can't figure out how to sort them by human-readable name without looping through twice which might not be ideal.

dropcube’s picture

Would be good to have the possibility to set 'weights' to profiles, and sort them by weight. For example, profiles may declare their weight in the hook_details:

function default_profile_details() {
  return array(
    'name' => 'Drupal',
    'description' => 'Select this profile to enable some basic Drupal functionality and the default theme.',
    'weight' => -10, 
  );
}
cburschka’s picture

That smells of feature creep to me. Is there a genuine use case for setting weights in a place that a) faces only the admin, b) is visible only once during installation, c) probably involves a very short list of profiles? Alphabetic sounds good enough to me...

webchick: Would another loop cost much performance? I could see something like this, in theory:

  foreach ($profiles as $profile) {
    include_once($profile->filename);
    // Load profile details.
    $function = $profile->name . '_profile_details';
    if (function_exists($function)) {
      $details = $function();
    }
    // If set, used [sic] defined name. Otherwise use file name.
    $name = isset($details['name']) ? $details['name'] : $profile->name;

// Split the loop here...

    $all_details[$name] = $details;
  }

  ksort($all_details);

  foreach ($all_details as $name => $details) {

// End changed code

    $form['profile'][$name] = array(
      '#type' => 'radio',
      '#value' => 'default',
      '#return_value' => $profile->name,
      '#title' => $name,
      '#description' => isset($details['description']) ? $details['description'] : '',
      '#parents' => array('profile'),
    );
  }
webchick’s picture

Status: Needs review » Needs work

Probably not. I was trying to keep this as simple as possible because I *really* want it back-ported to 6.x. The source code for our book is getting displayed as like:

Chapter 04: Blah
Chapter 09: Yadda
Chapter 05: Whee

Which is a big frickin' mess. ;)

But yes, it'd be more natural for it to sort by the human-readable name, and performance isn't really critical at all on this page. I'll give this another shot today.

cburschka’s picture

Probably not. I was trying to keep this as simple as possible because I *really* want it back-ported to 6.x. The source code for our book is getting displayed as like:

Chapter 04: Blah
Chapter 09: Yadda
Chapter 05: Whee

Book? I thought this issue was specifically related to install profiles?

webchick’s picture

It is.

The book we're writing (Drupal Jumpstart) comes with source code, which is a single Drupal 6 installation, a crap-ton of modules, and an install profile for each chapter to boot-strap some stuff. The listing of install profiles on page 1 of the install is listed in some sort of random order (I think it's by file creation date, which touch doesn't seem to affect).

So I'd rather these show up as:

Chapter 01:
Chapter 02:
Chapter 03:
Chapter 04:
...

Rather than in the current silly random order. ;)

webchick’s picture

Status: Needs work » Needs review
StatusFileSize
new2 KB

Ok, let's try this on for size.

dropcube’s picture

Status: Needs review » Needs work

The patch did not apply for me :(

webchick’s picture

Dang you, ever-shifting string concatenation coding standard! :)

webchick’s picture

Status: Needs work » Needs review
cburschka’s picture

Status: Needs review » Reviewed & tested by the community

The book we're writing (Drupal Jumpstart) comes with source code, which is a single Drupal 6 installation, a crap-ton of modules, and an install profile for each chapter to boot-strap some stuff.

Aha! Okay. The relation between books and profiles had confused me. ;)

---

Besides the custom profile I already have, I have created multiple copies of the default.profile: atrus, gandalf and zebra. atrus.profile has a name of "Profile Atrus" to distinguish human name from system name, the others are named by their file names.

Pre-patch:

- Gandalf
- Profile Atrus
- Zebra
- Ermarian Network
- Drupal

Looks kind of random.

Post-patch:

- Drupal
- Ermarian Network
- Gandalf
- Profile Atrus
- Zebra

And on 7.x:

- Zebra
- Gandalf
- Profile Atrus
- Small Business
- Ermarian Network
- Drupal

Post-patch:

- Drupal
- Ermarian Network
- Gandalf
- Profile Atrus
- Small Business
- Zebra

Looks good (though perhaps Dries wants a second review).

dropcube’s picture

Tested the 7.x patch and works as expected. So, confirm RTBC.

webchick’s picture

Thanks, dropcube and Arancaytar!

I just want to clarify that this is not an API change, although the function definition did change; I simply renamed $profiles to $profile_files to be more descriptive of what that variable actually holds.

dries’s picture

Status: Reviewed & tested by the community » Fixed

I've tested and reviewed these patches and they look good. I've committed it to DRUPAL-6 and CVS HEAD. Thanks all.

webchick’s picture

Oh, thank you!! :D

Anonymous’s picture

Status: Fixed » Closed (fixed)

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