Skip to content

Allow getenv() to work again with vlucas/phpdotenv 5.x#584

Merged
webflo merged 2 commits intodrupal-composer:9.xfrom
joelpittet:9.x
Dec 11, 2020
Merged

Allow getenv() to work again with vlucas/phpdotenv 5.x#584
webflo merged 2 commits intodrupal-composer:9.xfrom
joelpittet:9.x

Conversation

@joelpittet
Copy link
Copy Markdown
Contributor

https://github.com/vlucas/phpdotenv no longer works with getenv() by default in 5.x, you need to call explicitly Dotenv::createUnsafeImmutable to have those calls work. There are may places that use getenv() calls still including Drush.

-$dotenv = Dotenv::createImmutable(__DIR__);
+$dotenv = Dotenv::createUnsafeImmutable(__DIR__);

@webflo
Copy link
Copy Markdown
Member

webflo commented Dec 4, 2020

@joelpittet Using createImmutable is the recommend ways to use library and we updated our examples in this repo accordingly. 2d48c40

Could you try to update your project? I would review a PR to change the code in Drush.

@webflo webflo merged commit eeea242 into drupal-composer:9.x Dec 11, 2020
Comment thread load.environment.php
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();
$dotenv = Dotenv::createUnsafeImmutable(__DIR__);
$dotenv->load();
Copy link
Copy Markdown
Collaborator

@normanlolx normanlolx Dec 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you switched safeLoad for load here? Drush site install now fails when there's no .env file around.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just the docs indicating load() is the way to do it. I think I need a PR for Drush too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading the method and yeah thanks for keeping it safeLoad()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants