See #1014130: install_profile_info() does a file system scan on every request to admin/config (and etc.) for background.
If you want to get the name or version of the current install profile, the obvious choice is to use http://api.drupal.org/api/drupal/includes--install.inc/function/install_..., there's also http://api.drupal.org/api/drupal/includes--install.inc/function/drupal_i...
However install_profile_info() always does a full system scan, to get information about install profile dependencies, since it was originally designed for use only in the installer.
An easy workaround is to use system_get_info(), but that's a bit uglier since you have to provide defaults yourself.
Since both core and mollom were doing 2-3 second file directory scans to get this information (albeit on admin pages/ cache misses, but that's still 2-3 seconds), it would be good to have an API function for it that gets the information from the system table when it's available.
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedSubscribing.
@carlos8f's patch at #1014130-6: install_profile_info() does a file system scan on every request to admin/config (and etc.) might be a starting point for this - since it fixes the performance of install_profile_info() itself - although it still needs some work as per subsequent comments in that issue.
Comment #2
jhedstromThere is now
drupal_get_profile()
for this.Comment #3
David_Rothstein CreditAttribution: David_Rothstein commenteddrupal_get_profile() just returns the machine name of the profile, not any other info.
Looking at Drupal 8, install_profile_info() still does a filesystem scan, and still is used in several places in the code so I'm not sure a better way has ever been added.
Comment #14
JeroenTIs this issue still relevant for Drupal 9?
You can now do something like this:
the getExtensionInfo method still does a file system scan, but the result is cached in
cache_default
table with the keycore.extension.list.profile
.Comment #15
catchYes this is very outdated! Marking as such.