Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMPOSE_PROJECT_NAME is set incorrectly in shell #627

Open
4 tasks
rmccue opened this issue Sep 2, 2023 · 0 comments · May be fixed by #628
Open
4 tasks

COMPOSE_PROJECT_NAME is set incorrectly in shell #627

rmccue opened this issue Sep 2, 2023 · 0 comments · May be fixed by #628
Labels
bug Existing functionality isn't behaving as expected developer advocacy Developer Advocacy related tasks

Comments

@rmccue
Copy link
Member

rmccue commented Sep 2, 2023

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
@rmccue rmccue added the bug Existing functionality isn't behaving as expected label Sep 2, 2023
@rmccue rmccue linked a pull request Sep 2, 2023 that will close this issue
@missjwo missjwo added the developer advocacy Developer Advocacy related tasks label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing functionality isn't behaving as expected developer advocacy Developer Advocacy related tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants