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

Add new b_is_multisite() function #96

Closed
ghost opened this issue Jan 20, 2020 · 1 comment · Fixed by #97
Closed

Add new b_is_multisite() function #96

ghost opened this issue Jan 20, 2020 · 1 comment · Fixed by #97

Comments

@ghost
Copy link

ghost commented Jan 20, 2020

There are 3 possibilities when running a b command on a Backdrop site:

  1. It's a regular, non-multisite setup
  2. It's a multisite setup and you know the site
  3. It's a multisite setup and you don't know the site

In the first situation, any site-specific commands/information should be possible as the 'site' is the root dir of Backdrop (e.g. /settings.php).

In the second situation, you're either running the command from the site dir, or you specified the --url option, so the site is known. Site-specific commands/info are possible (e.g. the site is /sites/[site]/settings.php).

In the third situation, you're running the command from outside the site dir (e.g. Backdrop root) and you didn't specify the --url option, so the site is unknown. Site-specific commands/info are not possible (e.g. we don't know the site dir to use to find settings.php, and we can't use the root settings.php as it'll be empty).

Currently, situations 1 and 3 are indistinguishable as BACKDROP_SITE is not set in either case (either because it's the same as BACKDROP_ROOT or because we don't know what it is). This is problematic as we can't provide site-specific info for the first situation when we otherwise should be.

So I propose a new b_is_multisite() function that looks something like this:

function b_is_multisite($root) {
  $sites_php = $root . '/sites/sites.php';
  if (file_exists($sites_php)) {
    $sites = array();
    include $sites_php;
    if (!empty($sites)) {
      return TRUE;
    }
  }

  return FALSE;
}

This will allow us to distinguish between situations 1 and 3 and provide appropriate commands/info as necessary.

@ghost ghost added the type: enhancement label Jan 20, 2020
ghost pushed a commit that referenced this issue Jan 20, 2020
@ghost ghost added the pr: needs review label Jan 20, 2020
@ghost ghost closed this as completed in #97 Jan 20, 2020
ghost pushed a commit that referenced this issue Jan 20, 2020
@ghost ghost removed the pr: needs review label Jan 20, 2020
@ghost
Copy link
Author

ghost commented Jan 20, 2020

I've committed my PR. As we find a use for it we can start using it in the code.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0 participants