The Wayback Machine - https://web.archive.org/web/20210719173816/https://github.com/laravel/laravel/pull/5409
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

[8.x] Fix PHPUnit bool server consts result in null #5409

Merged
merged 1 commit into from Sep 14, 2020

Conversation

@hettiger
Copy link
Contributor

@hettiger hettiger commented Sep 14, 2020

After updating to Laravel 8 I suddenly had my test suite failing because telescope would not be disabled properly by phpunit.xml anymore.
This change fixed my test suite.

I've also created a clean Laravel 8 project and added some tests to demonstrate the issue:
hettiger/laravel-env-demo@908d340

Maybe this needs to be addressed in PHPUnit. However I'm adding this workaround here because it's a viable solution IMHO.
Maybe should add a note on this in the docs and be done with it…?

After updating to Laravel 8 I suddenly had my test suite failing because telescope would not be disabled properly by `phpunit.xml` anymore.
This changes fixed my test suite.

I've also created a clean Laravel 8 project and added some tests to demonstrate the issue:
hettiger/laravel-env-demo@908d340

Maybe this needs to be addressed in PHPUnit. However I'm adding this workaround here because it's a viable solution IMHO.
Maybe should add a note on this in the docs and be done with it…?
@taylorotwell taylorotwell merged commit 1c4af33 into laravel:master Sep 14, 2020
1 check passed
1 check passed
continuous-integration/styleci/pr The analysis has passed
Details
@GrahamCampbell GrahamCampbell changed the title Fix PHPUnit bool server consts result in null [8.x] Fix PHPUnit bool server consts result in null Sep 14, 2020
realodix added a commit to realodix/urlhub that referenced this pull request Sep 14, 2020
@sergiy-petrov
Copy link

@sergiy-petrov sergiy-petrov commented Sep 14, 2020

@GrahamCampbell @hettiger I do believe it's due to this change in DotEnv package
https://github.com/vlucas/phpdotenv/blob/7e6837db20ebb360f2b97fa87411d11a4b500bf6/src/Repository/Adapter/ServerConstAdapter.php#L44

Now server variables expect to be strings only, however it could be bool/int as well IMO.

@sergiy-petrov
Copy link

@sergiy-petrov sergiy-petrov commented Sep 14, 2020

This change in Repository/Adapter/ServerConstAdapter.php

vlucas/phpdotenv@4.1...5.0

зображення

@hettiger hettiger deleted the hettiger:patch-2 branch Sep 14, 2020
@hettiger
Copy link
Contributor Author

@hettiger hettiger commented Sep 14, 2020

Thanks for clarification @sergiy-petrov; LGTM.

Feel free to continue the discussion in a new issue at vlucas/phpdotenv.
If the dependency changes this can simply be reverted.

@GrahamCampbell
Copy link
Member

@GrahamCampbell GrahamCampbell commented Sep 14, 2020

The bug is in PHPUnit. The $_SERVER variable is meant to have type array<string, string>. PHPUnit shouldn't be converting the string "false" to the boolean false when it is loading stuff into that array.

@GrahamCampbell
Copy link
Member

@GrahamCampbell GrahamCampbell commented Sep 14, 2020

Ping @sebastianbergmann for comment. Maybe there's a use case you know that really needs to not have environment variables be strings. Usually, I'd expect people using environment variables to convert them to an int or a bool when they come to use them, and not mess with how they are stored in the server array.

@GrahamCampbell
Copy link
Member

@GrahamCampbell GrahamCampbell commented Sep 14, 2020

I am going to just patch phpdotenv 5.x to convert boolean values from $_ENV and $_SERVER to strings, instead of skipping over them as invalid. This should resolve this issue for people, without needing this hack.

@sergiy-petrov
Copy link

@sergiy-petrov sergiy-petrov commented Sep 14, 2020

@GrahamCampbell would be great. Thanks!

@GrahamCampbell
Copy link
Member

@GrahamCampbell GrahamCampbell commented Sep 14, 2020

phpdotenv v5.2.0 has now been released, with this fixed.

taylorotwell pushed a commit that referenced this pull request Sep 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants