From 31d778694d459f6b1a89881ac99362fa1a66c6f2 Mon Sep 17 00:00:00 2001 From: Daniel Love Date: Fri, 7 Jan 2022 15:02:24 -0700 Subject: [PATCH] Updating Dotenv::getConfig to support environments with full "production" name. Updating Dotenv::getDatabaseName to provide helpful output in Drush context for multi-site config with dis-allowed default site. Updating change log. --- CHANGELOG.md | 11 +++++++++-- src/Dotenv.php | 9 +++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52caa83..3723a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,18 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi ## [Unreleased][unreleased] +## [0.1.11] - 2022-01-07 + +### Changed +- Updating Dotenv::getConfig to support environments with full "production" name. +- Updating Dotenv::getDatabaseName to provide helpful output in Drush context for multi-site config with dis-allowed default site. + ## [0.1.10] - 2022-01-04 ### Changed - Disallowed access to `default` site in a multi-site install by default. -- Added support for `$database` variable alteration. +- Added support for `$databases` variable alteration. - Added support for `FILE_PUBLIC_PATH` environment variable. - Added support for `FILE_PRIVATE_PATH` environment variable. - Added support for `FILE_TEMP_PATH` environment variable. @@ -81,7 +87,8 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi **Initial release!** -[unreleased]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.10...main +[unreleased]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.11...main +[0.1.11]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.9...0.1.11 [0.1.10]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.9...0.1.10 [0.1.9]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.8...0.1.9 [0.1.8]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.7...0.1.8 diff --git a/src/Dotenv.php b/src/Dotenv.php index 46b3e42..0c04717 100644 --- a/src/Dotenv.php +++ b/src/Dotenv.php @@ -151,6 +151,7 @@ public function getConfig(): array break; case 'prod': + case 'production': $config['environment_indicator.indicator'] = [ 'name' => 'Production', 'fg_color' => '#ffb6b6', @@ -195,8 +196,12 @@ public function getDatabaseName(): string // Multi-site configuration detected. Use the site name. $result = $this->getSiteName(); if ($result === 'default' && !$this->isMultiSiteDefaultSiteAllowed()) { - header("HTTP/1.1 401 Unauthorized"); - die('Unauthorized'); + if (PHP_SAPI === 'cli') { + throw new \Exception('The "default" site in this multi-site install is not allowed. Please run something like `drush -l {{site}}` instead.'); + } else { + header("HTTP/1.1 401 Unauthorized"); + die('Unauthorized'); + } } } else { $result = substr($result, 1);