File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
44
55## [ Unreleased] [ unreleased ]
66
7+ ## [ 0.3.1] - 2022-05-19
8+
9+ ### Changed
10+
11+ - Added support for ` DATABASE_NAME ` variables.
12+
713## [ 0.3.0] - 2022-05-17
814
915### Changed
@@ -149,7 +155,8 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
149155
150156** Initial release!**
151157
152- [ unreleased ] : https://github.com/unleashedtech/dotenv-drupal/compare/0.3.0...main
158+ [ unreleased ] : https://github.com/unleashedtech/dotenv-drupal/compare/0.3.1...main
159+ [ 0.3.1 ] : https://github.com/unleashedtech/dotenv-drupal/compare/0.2.1...0.3.1
153160[ 0.3.0 ] : https://github.com/unleashedtech/dotenv-drupal/compare/0.2.1...0.3.0
154161[ 0.2.1 ] : https://github.com/unleashedtech/dotenv-drupal/compare/0.2.0...0.2.1
155162[ 0.2.0 ] : https://github.com/unleashedtech/dotenv-drupal/compare/0.1.17...0.2.0
Original file line number Diff line number Diff line change @@ -168,6 +168,12 @@ $dotenv->setAppName('earth');
168168// ...
169169```
170170
171+ The database name for a site can be overridden via definition of a ` {{ app }}__{{ site }}__DATABASE_NAME `
172+ environment variable:
173+ ``` dotenv
174+ EARTH__ANTARCTICA__DATABASE_NAME=ant
175+ ```
176+
171177#### FILE_PUBLIC_PATH
172178Allows you to override the default ` $settings['file_public_path'] ` value:
173179
Original file line number Diff line number Diff line change @@ -254,14 +254,18 @@ public function getDatabaseName(): string
254254 return $ this ->databaseName ;
255255 }
256256 $ result = parse_url ($ this ->get ('database_url ' ), PHP_URL_PATH );
257- if (NULL === $ result || trim ($ result ) === '/ ' ) {
258- // Multi-site configuration detected. Use the site name.
259- $ result = $ this ->getSiteName ();
260- if ($ result === 'default ' && !$ this ->isMultiSiteDefaultSiteAllowed ()) {
261- if (PHP_SAPI === 'cli ' ) {
262- throw new \Exception ('The "default" site in this multi-site install is not allowed. Please run something like `drush -l {{site}}` instead. ' );
263- } else {
264- header ("HTTP/1.1 401 Unauthorized " );
257+ if (NULL === $ result || trim ($ result ) === '/ ' || trim ($ result ) === '' ) {
258+ // Multi-site configuration detected. Try to use the DATABASE_NAME variable.
259+ $ result = $ this ->get ('database_name ' );
260+ if (! $ result ) {
261+ // Fall back to using the site name.
262+ $ result = $ this ->getSiteName ();
263+ if ($ result === 'default ' && !$ this ->isMultiSiteDefaultSiteAllowed ()) {
264+ if (PHP_SAPI === 'cli ' ) {
265+ throw new \DomainException ('The "default" site in this multi-site install is not allowed. Please run something like `drush -l {{site}}` instead. ' );
266+ }
267+
268+ \header ('HTTP/1.1 401 Unauthorized ' );
265269 die ('Unauthorized ' );
266270 }
267271 }
You can’t perform that action at this time.
0 commit comments