Skip to content

Commit 625cf95

Browse files
committed
Issue #1006714 by Steven Jones, chx, mr.baileys, xjm, carlos8f: Fixed drupal_get_path() doesn't work for profiles.
1 parent 4c45ee1 commit 625cf95

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎includes/bootstrap.inc‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,11 @@ function drupal_get_filename($type, $name, $filename = NULL) {
828828
// drupal_static().
829829
static $files = array(), $dirs = array();
830830

831+
// Profiles are a special case: they have a fixed location and naming.
832+
if ($type == 'profile') {
833+
$profile_filename = "profiles/$name/$name.profile";
834+
$files[$type][$name] = file_exists($profile_filename) ? $profile_filename : FALSE;
835+
}
831836
if (!isset($files[$type])) {
832837
$files[$type] = array();
833838
}

‎modules/simpletest/tests/bootstrap.test‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,18 @@ class BootstrapGetFilenameTestCase extends DrupalUnitTestCase {
350350
// Retrieving the location of a theme engine.
351351
$this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'themes/engines/phptemplate/phptemplate.engine', t('Retrieve theme engine location.'));
352352

353-
// Retrieving a file that is definitely not stored in the database.
353+
// Retrieving the location of a profile. Profiles are a special case with
354+
// a fixed location and naming.
354355
$this->assertIdentical(drupal_get_filename('profile', 'standard'), 'profiles/standard/standard.profile', t('Retrieve install profile location.'));
356+
357+
// When a file is not found in the database cache, drupal_get_filename()
358+
// searches several locations on the filesystem, including the DRUPAL_ROOT
359+
// directory. We use the '.script' extension below because this is a
360+
// non-existent filetype that will definitely not exist in the database.
361+
// Since there is already a scripts directory, drupal_get_filename() will
362+
// automatically check there for 'script' files, just as it does for (e.g.)
363+
// 'module' files in modules.
364+
$this->assertIdentical(drupal_get_filename('script', 'test'), 'scripts/test.script', t('Retrieve test script location.'));
355365
}
356366
}
357367

‎scripts/test.script‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This file is for testing purposes only.
2+
3+
It is used to test the functionality of drupal_get_filename(). See
4+
BootstrapGetFilenameTestCase::testDrupalGetFilename() for more information.

0 commit comments

Comments
 (0)