From 41aef912af6a0772f59871481f57e77329629330 Mon Sep 17 00:00:00 2001
From: Bob Vincent <bobvin@pillars.net>
Date: Thu, 30 Jun 2011 14:20:08 -0400
Subject: [PATCH 1/2] Issue #1136820 by mikey_p, catch: Allow drupal_get_filename() to work for the installed profile. (test-only patch)

---
 modules/simpletest/tests/bootstrap.test |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test
index 14c16a95b6d0c4e694ca01a53615fb472b58b1f7..93ba67f8271cef0fa88c0736135314702f1e63a9 100644
--- a/modules/simpletest/tests/bootstrap.test
+++ b/modules/simpletest/tests/bootstrap.test
@@ -327,7 +327,7 @@ class BootstrapGetFilenameTestCase extends DrupalUnitTestCase {
 
   public static function getInfo() {
     return array(
-      'name' => 'Get filename test',
+      'name' => 'Get filename without database',
       'description' => 'Test that drupal_get_filename() works correctly when the file is not found in the database.',
       'group' => 'Bootstrap',
     );
@@ -355,6 +355,23 @@ class BootstrapGetFilenameTestCase extends DrupalUnitTestCase {
   }
 }
 
+class BootstrapDrupalGetFileNameDatabaseTestCase extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Get filename with database',
+      'description' => 'Test that drupal_get_filename() works with the database available',
+      'group' => 'Bootstrap',
+    );
+  }
+
+  /**
+   * Test drupal_get_filename() with an install profile.
+   */
+  function testDrupalGetFilenameInstallProfile() {
+    $this->assertIdentical(drupal_get_filename('profile', 'standard'), 'profiles/standard/standard.profile', t('Retrieve install profile location.'));
+  }
+}
+
 class BootstrapTimerTestCase extends DrupalUnitTestCase {
 
   public static function getInfo() {
-- 
1.7.4.1


From b3565fb9eafd11cade26705289de369f2f902cc2 Mon Sep 17 00:00:00 2001
From: Bob Vincent <bobvin@pillars.net>
Date: Thu, 30 Jun 2011 14:20:49 -0400
Subject: [PATCH 2/2] Issue #1136820 by mikey_p, catch: Allow drupal_get_filename() to work for the installed profile. (test+fix patch)

---
 includes/bootstrap.inc |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 18f44e2339b1f2ff289fb2b7ba10aeeb646def94..18feabbb3bee9cdcc4fc4745d154347f9c029dad 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -587,6 +587,12 @@ function drupal_get_filename($type, $name, $filename = NULL) {
   else {
     try {
       if (function_exists('db_query')) {
+        // Profiles are saved as $type = 'module' in the {system} table, ensure
+        // that drupal_get_filename('profile', $name); works both with and
+        // without the database available by converting the argument here.
+        if ($type == 'profile') {
+          $type = 'module';
+        }
         $file = db_query("SELECT filename FROM {system} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))->fetchField();
         if (file_exists(DRUPAL_ROOT . '/' . $file)) {
           $files[$type][$name] = $file;
-- 
1.7.4.1

