Problem/Motivation

#3453474: CLI entry point in Drupal Core introduced Drupal\Core\Command\DrupalApplication and deprecated Drupal\Core\Command\BootableCommandTrait. Many of us worked on and reviewed #3453474, yet we all seemed to miss this incredibly important detail from BootableCommandTrait:

  /**
   * Gets the site path.
   *
   * Defaults to 'sites/default'. For testing purposes this can be overridden
   * using the DRUPAL_DEV_SITE_PATH environment variable.
   *
   * @return string
   *   The site path to use.
   */
  protected function getSitePath(): string {
    return getenv('DRUPAL_DEV_SITE_PATH') ?: 'sites/default';
  }

@phenaproxima reported in Slack:

So, I know BootableCommandTrait is deprecated (good riddance; I wrote it). Nice. However, how do I force dr to operate within the confines of the test site in a functional test? Previously, this was done by passing the DRUPAL_DEV_SITE_PATH env var. What do I do now?

Steps to reproduce

Proposed resolution

Restore support for DRUPAL_DEV_SITE_PATH in DrupalApplication for all CLI commands.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3597406

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dww created an issue. See original summary.

dww’s picture

Assigned: dww » Unassigned
Status: Active » Needs review

Probably needs tests, but as an urgent hot-fix, maybe having @phenaproxima confirm drupal_cms tests are happy with this change is Good Enough(tm)?

phenaproxima made their first commit to this issue’s fork.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

This helps me immensely. I worked a tad on this patch, yes, but given that this broke CMS's development process, I don't mind RTBCing it.

dww’s picture

FWIW, I reviewed @phenaproxima's commit here. It makes sense to me. We prefer invoking via vendor/bin/dr since that gives composer a chance to setup the right class loader. He explained that drupal_cms uses a drupal/core-recommended setup, so things aren't in the same places that we might expect from a raw core checkout like the default core test suite. His commit allows RecipeTestTrait:: applyRecipe() to work regardless of how core is installed. +1 to that change (even if it's slightly out of scope about DRUPAL_DEV_SITE_PATH.

So both authors reviewed each other's work. RTBC +1.

dww’s picture

  • catch committed d90d4c41 on 11.4.x
    fix: #3597406 [regression] DrupalApplication (for 'dr') needs to support...

  • catch committed df69c6ea on 11.x
    fix: #3597406 [regression] DrupalApplication (for 'dr') needs to support...

  • catch committed 09d9f4d3 on main
    fix: #3597406 [regression] DrupalApplication (for 'dr') needs to support...
catch’s picture

Version: main » 11.4.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: +Needs followup

I'm going to go ahead here because it's blocking Drupal CMS testing, but tagging with 'needs follow-up' in case we want an explicit follow-up to deprecate this apart from the two issue linked by @mradclifffe

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.