framework: compact with undefined variable breaks on PHP 7.3
- Laravel Version: 5.4
- PHP Version: 7.3
- Database Driver & Version:
MySQL
Description:
when trying to compact
the operator
variable which does not exits, php 7.3 will throw an ErrorException
.
ErrorException
compact(): Undefined variable: operator
Steps To Reproduce:
Chain a has
method onto the Query/Builder
in php 7.3.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 13
- Comments: 36 (12 by maintainers)
@landadelcarmen composer update
this work for me
downgraded to PHP 7.1.3.this work for me
@tihootech it’s not the goal of Laravel to be responsible for compatibility of breaking changes within PHP versions (except very rare circumstances, when it becomes evident that a change in a PHP version is actually a very buggy behavior, I believe I’ve seen that case but don’t remember the details).
The PHP group made the decision to make a breaking change in
compact()
and all PHP code in the world has to be adapted to it, if people want to use 7.3+ with it.I’m no expert on this topic, but I believe due to it’s special nature how
compact()
works, you can’t write an easy function shim because you would need to asses the callers scope which isn’t possible in pure user land.My advice: before upgrading PHP, read through it’s great upgrade guide and apply changes as necessary.
@JacobBennett Hey Jacob. We don’t support 5.4 anymore. Does this also happen for you on 5.5 or 5.7?
Hey guys. Getting the same issue with 5.8.24 and PHP 7.3.4. Isn’t the fix on 5.8 as well?
composer update
solve it for you? Think this was fixed in 5.5