Generated with the help of an LLM.

Problem/Motivation

On a multisite, dr uses sites/default in cases where another site was requested:

  • dr cache:rebuild ignores --url, DRUPAL_URI and DRUPAL_DEV_SITE_PATH. It builds its request from globals.
  • For all commands, --url and DRUPAL_URI never select a site directory. Request::create() leaves SCRIPT_NAME empty, so DrupalKernel::findSitePath() matches nothing.
  • A URI without a scheme (--url=example.com, as in the option's help text) is parsed as a path.

Steps to reproduce

Install sites/default and sites/dev, add sites/sites.php, run dr cache:rebuild --url=https://dev. The caches of sites/default are rebuilt.

Proposed resolution

  • Add DrupalApplication::getSitePath(), used by bootstrap() and cache:rebuild. It sets a script name from the URI path before calling findSitePath().
  • drupal_rebuild() takes an optional $site_path.
  • DrupalApplication::getUri() prepends http:// when the URI has no scheme.

API changes

drupal_rebuild() gains an optional third parameter.

Issue fork drupal-3638000

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

moshe weitzman created an issue. See original summary.

moshe weitzman’s picture

Status: Active » Needs review
moshe weitzman’s picture