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

Bee command generates this error "Domain access failed to load during phase: bootstrap include." #52

Open
stpaultim opened this issue Jan 7, 2025 · 4 comments
Labels
type - bug report Something isn't working

Comments

@stpaultim
Copy link
Member

stpaultim commented Jan 7, 2025

As a follow-up to: #50

I am still getting this error in log after running bee uli (inside of DDEV). But, the command is working and the site seems fine.

Domain access failed to load during phase: bootstrap include. Please check your settings.php file and site configuration.

I ran this problem through chatGPT and got the following suggestion:

The error occurs because the Domain module expects web-specific variables that are missing in the CLI context. By detecting and adapting for CLI use cases (e.g., skipping or modifying the bootstrap process), you can eliminate this error without affecting normal module functionality.

Some testing indicates that this may be the correct answer. It seems that we might want to simply avoid generating the error message in a CLI context.

I also considered modifying the error message in a CLI context. Which is hacky and not very ideal, but easier to implement.

    if (PHP_SAPI === 'cli') {
      // Check if for CLI context and modify error message.
      $error .= ' <br>If triggered by a BEE command and site is working fine, you may ignore this.';
    }

I'm not suggesting this aswer now, because of uncertainty regarding possible unexpected consequences. But throwing it out there to help with future solutions.

@yorkshire-pudding
Copy link
Collaborator

Perhaps try bee uli --base-url=https://www.example.com
see https://github.com/backdrop-contrib/bee/wiki/Usage#user-login

@laryn
Copy link
Member

laryn commented Jan 7, 2025

I can confirm the original report, and (if Domain Theme is enabled) it is preceded by this error:

Warning: Undefined array key "domain_id" in domain_theme_custom_theme() (line 26 of /var/www/html/modules/contrib/domain/domain_theme/domain_theme.module).

I tested with the --base-url flag and still see the warnings in the log afterwards. When I try --base-url with a non-default domain URL, it doesn't seem to provide the login link correctly -- it still presents it with the default domain URL.

It may be relevant that I'm testing locally with DDEV here. Particularly I'm wondering about how the default bee command in DDEV specifies a uri value:

@laryn
Copy link
Member

laryn commented Jan 7, 2025

This doesn't completely solve it for DDEV (ie. it does solve the error/warning but it always uses the default domain base url in the return for user login), but more generally would something like this be appropriate in domain_init(), just above the // Error handling... section to populate $_domain for bee?

  // Handle CLI requests.
  if (function_exists('bee_is_cli') && bee_is_cli() && !isset($_domain['domain_id'])) {
    global $argv;
    if (is_array($argv)) {
      foreach ($argv as $value) {
        if (strpos($value, '--base-url=') !== FALSE) {
          $subdomain_parts = explode('//', $value);
          $_domain = domain_lookup(NULL, $subdomain_parts[1]);
        }
      }
    }
  }

The DDEV url thing isn't a dealbreaker. If the Force domain editing from the primary domain setting is turned off, I should just be able to copy/paste the path generated by bee uli onto the alternate subdomain.

@laryn
Copy link
Member

laryn commented Jan 7, 2025

Alternately, if the base-url trick doesn't work anywhere, we could just skip the extra processing and load the domain_default(TRUE) for bee requests...

@yorkshire-pudding yorkshire-pudding added the type - bug report Something isn't working label Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type - bug report Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants