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
php7.4 getCallerFromStackTrace not returning an array causes ErrorException: Trying to access array offset on value of type null #804
Comments
Can we create a regression test for this? |
Trying to dig into this, hoping I'm on the right track. When running a command such as But, for tests that use the RefreshDatabase trait, all of that work comes from code in the vendor directory, which makes getCallerFromStackTrace() return null (since it finds no code outside the vendor directory in the stack trace), and that causes PHP 7.4 to throw an error when we attempt to access that null value as an array in QueryWatcher.php.
Hoping that helps someone else write the regression test - I'm taking a stab at it, but this isn't my strong suit by any means, hoping someone with sharper skills can come in and save the day here! |
The reason this doesn't crop up in Telescope's existing tests is because all test cases extend the FeatureTestCase and that class has its own setUp() method. As a result, that FeatureTestCase class (outside the vendor directory) is in the stack trace, so the getCallerFromStackTrace() method doesn't return null. I was able to alleviate this issue in my own repository by simply adding the following code to Laravel's base TestCase class it provides in the tests/ directory:
That ensures that my base test case, outside the vendor directory, will always be in the stack trace, so the issue never comes up. Beyond a regression test, not sure what the best approach is to fixing this, but I figured I'd share what I've been finding as I dig into this. |
on <server name="TELESCOPE_ENABLED" value="false"/> after that all tests will run correct :) |
I didn't realise that you were doing this in a testing environment before. Please disable Telescope in your test suite as explained above. |
Description:
if getCallerFromStackTrace doesn't return an array, QueryWatcher.php at line 46 will throw an exception :
ErrorException: Trying to access array offset on value of type null
https://www.php.net/manual/en/migration74.incompatible.php#migration74.incompatible.core.non-array-access
Steps To Reproduce:
Any scenario in which getCallerFromStackTrace can't find a caller. In my case I ran a test contained in a vendor component that had to write to a test database.
The text was updated successfully, but these errors were encountered: