Skip to content

COMPOSE_PROJECT_NAME is set incorrectly in shell #627

@rmccue

Description

@rmccue

Steps to reproduce:

  1. Run composer server shell
  2. Inside the container, run wp
  3. Observe Error: Site 'your-project.altis.dev.' not found. Define DOMAIN_CURRENT_SITE in 'wp-config.php' or use --url= to override.

This occurs because we set the host name using COMPOSE_PROJECT_NAME and COMPOSE_PROJECT_TLD:

if ( empty( $_SERVER['HTTP_HOST'] ) ) {
$_SERVER['HTTP_HOST'] = getenv( 'COMPOSE_PROJECT_NAME' ) . '.' . getenv( 'COMPOSE_PROJECT_TLD' );
}

However, the latter is not defined, so we get a trailing .

Worse, COMPOSE_PROJECT_NAME is inconsistent; usually, it refers only to the subdomain:

'COMPOSE_PROJECT_NAME' => $this->get_project_subdomain(),
'COMPOSE_PROJECT_TLD' => $this->get_project_tld(),

However, the docker-compose configuration instead sets this to the full domain:

'COMPOSE_PROJECT_NAME' => $this->hostname,

These need to be made consistent; this probably should have been done in #341 and #465, but we missed it. (You can verify this by running env inside composer server shell)

We also need to fix the HTTP_HOST override, as if we're in Codespaces, the TLD is not set at all. COMPOSE_PROJECT_NAME seems to only be used in this code, so it should be fine to update this.

I would suggest we introduce a new environment variable instead of reusing this, since COMPOSE_PROJECT_NAME has an existing specific purpose.

Acceptance criteria:

  • COMPOSE_PROJECT_NAME contains only the docker-compose project name
  • COMPOSE_PROJECT_TLD contains the TLD inside the shell
  • ALTIS_DEFAULT_HOST contains the default HTTP_HOST
  • Running wp with no --url parameter inside the shell uses ALTIS_DEFAULT_HOST correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugExisting functionality isn't behaving as expecteddeveloper advocacyDeveloper Advocacy related tasks

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions