Verified Commit bd169751 authored by godotislate's avatar godotislate
Browse files

fix: #3597692 [regression] The 'dr' command doesn't set DRUPAL_TEST_IN_CHILD_SITE

By: phenaproxima
By: dww
By: kingdutch
(cherry picked from commit 75547409)
parent 58cd4bd0
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -111,6 +111,8 @@ protected function bootstrap(): bool {
      // @todo Refactor `bootEnvironment()' so that we can use the parts we need
      // but leave the error handler alone.
      // @see https://www.drupal.org/node/2690035
      // Define the DRUPAL_TEST_IN_CHILD_SITE based on if we're inside a test.
      DrupalKernel::setupDrupalTestInChildSite($kernel->getAppRoot());
      $sitePath = DrupalKernel::findSitePath($request, TRUE);
      $kernel->setSitePath($sitePath);
      Settings::initialize($kernel->getAppRoot(), $kernel->getSitePath(), $this->classloader);
+23 −7
Original line number Diff line number Diff line
@@ -1168,7 +1168,29 @@ public static function bootEnvironment($app_root = NULL) {
    mb_internal_encoding('utf-8');
    mb_language('uni');

    // Indicate that code is operating in a test child site.
    // Set DRUPAL_TEST_IN_CHILD_SITE if we're inside a test.
    static::setupDrupalTestInChildSite($app_root);

    // Set the Drupal custom error handler.
    set_error_handler('_drupal_error_handler');
    set_exception_handler('_drupal_exception_handler');

    static::$isEnvironmentInitialized = TRUE;
  }

  /**
   * Define the DRUPAL_TEST_IN_CHILD_SITE constant as appropriate.
   *
   * @param string $app_root
   *   The path to the application root.
   *
   * @internal This method is only intended to be called by this class and
   *   \Drupal\Core\Command\DrupalApplication. We aim to remove the need for it
   *   without a BC layer during Drupal 12.
   * @see https://www.drupal.org/node/2690035
   */
  public static function setupDrupalTestInChildSite(string $app_root): void {
    // Indicate if code is operating in a test child site or not.
    if (!defined('DRUPAL_TEST_IN_CHILD_SITE')) {
      if ($test_prefix = drupal_valid_test_ua()) {
        $test_db = new TestDatabase($test_prefix);
@@ -1191,12 +1213,6 @@ public static function bootEnvironment($app_root = NULL) {
        define('DRUPAL_TEST_IN_CHILD_SITE', FALSE);
      }
    }

    // Set the Drupal custom error handler.
    set_error_handler('_drupal_error_handler');
    set_exception_handler('_drupal_exception_handler');

    static::$isEnvironmentInitialized = TRUE;
  }

  /**