diff --git a/core/includes/common.inc b/core/includes/common.inc index 80cfade9a2d9ec51e161e30960e6cb8540522090..b4ff053b0418e29c96228de22f18c29407d14a62 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -193,8 +193,10 @@ function drupal_get_region_content($region = NULL, $delimiter = ' ') { * installation state. At all other times, the "install_profile" setting will be * available in settings.php. * - * @return $profile - * The name of the installation profile. + * @return string|null $profile + * The name of the installation profile or NULL if no installation profile is + * currently active. This is the case for example during the first steps of + * the installer or during unit tests. */ function drupal_get_profile() { global $install_state; @@ -205,11 +207,12 @@ function drupal_get_profile() { $profile = $install_state['parameters']['profile']; } else { - $profile = ''; + $profile = NULL; } } else { - $profile = Settings::get('install_profile') ?: 'standard'; + // Fall back to NULL, if there is no 'install_profile' setting. + $profile = Settings::get('install_profile'); } return $profile; diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index 2acf138fca1662e0ffa08097f269e4ae63637ea8..6c13c8a9f4184ff468f338582366e849db03bbb3 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -266,4 +266,14 @@ function testEnableModulesTheme() { $this->assertTrue(drupal_render($element)); } + /** + * Tests that drupal_get_profile() returns NULL. + * + * As the currently active installation profile is used when installing + * configuration, for example, this is essential to ensure test isolation. + */ + public function testDrupalGetProfile() { + $this->assertNull(drupal_get_profile()); + } + }